Exemplo n.º 1
0
def test_plain():
    simple_path = "level1_1.level2_1.level3"
    getters = getter_tree(SAMPLE1, simple_path)

    assert len(getters) == 3
    assert lookup(
        *getters)(SAMPLE1) == SAMPLE1["level1_1"]["level2_1"]["level3"]
Exemplo n.º 2
0
def test_subarrays():
    path = "level1_1.level2_1[].level3[].data"
    getters = getter_tree(SAMPLE4, path)

    assert lookup(*getters)(SAMPLE4) == [["value1", "value2"],
                                         ["value3", "value4"],
                                         ["value5", "value6"]]
Exemplo n.º 3
0
def test_array_with_tree():
    path = "level1_1.level2_1[].level3.data"
    getters = getter_tree(SAMPLE3, path)

    assert len(getters) == 4
    assert lookup(*getters)(SAMPLE3) == ["value1", "value2", "value3"]
Exemplo n.º 4
0
def test_array():
    path = "level1_1.level2_1[].level3"
    getters = getter_tree(SAMPLE2, path)

    assert len(getters) == 3
    assert lookup(*getters)(SAMPLE2) == ["value1", "value2", "value3"]
Exemplo n.º 5
0
def test_plain():
    simple_path = "level1_1.level2_1.level3"
    getters = getter_tree(SAMPLE1, simple_path)

    assert len(getters) == 3
    assert lookup(*getters)(SAMPLE1) == SAMPLE1["level1_1"]["level2_1"]["level3"]
Exemplo n.º 6
0
def test_subarrays():
    path = "level1_1.level2_1[].level3[].data"
    getters = getter_tree(SAMPLE4, path)

    assert lookup(*getters)(SAMPLE4) == [
        ["value1", "value2"], ["value3", "value4"], ["value5", "value6"]]
Exemplo n.º 7
0
def test_array_with_tree():
    path = "level1_1.level2_1[].level3.data"
    getters = getter_tree(SAMPLE3, path)

    assert len(getters) == 4
    assert lookup(*getters)(SAMPLE3) == ["value1", "value2", "value3"]
Exemplo n.º 8
0
def test_array():
    path = "level1_1.level2_1[].level3"
    getters = getter_tree(SAMPLE2, path)

    assert len(getters) == 3
    assert lookup(*getters)(SAMPLE2) == ["value1", "value2", "value3"]