Exemplo n.º 1
0
def test_traverse_doc_handles_lists_2():
    path = 'sourceResource.language.name'
    doc = {
        'sourceResource': {
            'language': [{
                'name': 'English'
            }, {
                'name': 'Spanish'
            }]
        }
    }
    result = v2_handlers.traverse_doc(path, doc)
    assert result == ['English', 'Spanish']
Exemplo n.º 2
0
def test_traverse_doc_handles_object():
    path = 'a'
    doc = {'a': {'b': 'c'}}
    result = v2_handlers.traverse_doc(path, doc)
    assert result == {'b': 'c'}
Exemplo n.º 3
0
def test_traverse_doc_handles_empty_list():
    path = 'a'
    doc = {'a': []}
    result = v2_handlers.traverse_doc(path, doc)
    assert result is None
Exemplo n.º 4
0
def test_traverse_doc_handles_nonexistent_field_2():
    path = 'a.b'
    doc = {'a': 'x'}
    result = v2_handlers.traverse_doc(path, doc)
    assert result is None
Exemplo n.º 5
0
def test_traverse_doc_handles_nonexistent_field_1():
    path = 'a.b.c.d'
    doc = {'a': {'b': [{'foo': 'x'}]}}
    result = v2_handlers.traverse_doc(path, doc)
    assert result is None
Exemplo n.º 6
0
def test_traverse_doc_handles_nested_arrays_and_objects():
    path = 'a.b.c.d'
    doc = {'a': {'b': [{'c': [{'d': 'the value'}]}]}}
    result = v2_handlers.traverse_doc(path, doc)
    assert result == 'the value'
Exemplo n.º 7
0
def test_traverse_doc_handles_strings():
    path = 'sourceResource.language.name'
    doc = {'sourceResource': {'language': {'name': 'English'}}}
    result = v2_handlers.traverse_doc(path, doc)
    assert result == 'English'