Esempio n. 1
0
def test_has_key_in_conjunction_finds_node(sample_traced_object):
    obj = treehorn.GoDown(condition=treehorn.HasKey("c1") & treehorn.HasKey("e"), label='sample')
    result = list(obj(sample_traced_object))
    assert result[0] == treehorn.splitter(
            {'sample': {"c1": "d1", "some_list": [10, 20, 40], "e": "whatever"}}
    )
    assert len(result) == 1
Esempio n. 2
0
def test_has_key_in_disjunction_negation_finds_node(sample_traced_object):
    obj = treehorn.GoDown(
        condition=treehorn.HasKey("c1") & (~treehorn.HasKey("nonexistent")), label='sample'
    )
    result = list(obj(sample_traced_object))
    # result = list(obj._generator)
    assert result[0] == treehorn.splitter(
            {'sample': {"c1": "d1", "some_list": [10, 20, 40], "e": "whatever"}}
    )
    assert len(result) == 1
Esempio n. 3
0
def test_use_splitter_to_instantiate(sample_dictionary):
    obj = treehorn.splitter(sample_dictionary)
    assert isinstance(obj, (treehorn.TracedObject,))
Esempio n. 4
0
def sample_traced_object(sample_dictionary):
    return treehorn.splitter(sample_dictionary)
Esempio n. 5
0
def test_traced_object_not_equal():
    d1 = {"bar": ["bar", "baz"], "qux": 0}
    d2 = {"bar": ["bar", "baz"], "qux": 1}
    assert treehorn.splitter(d1) != treehorn.splitter(d2)
Esempio n. 6
0
def test_traced_object_equality():
    d = {"bar": ["bar", "baz"], "qux": 0}
    assert treehorn.splitter(d) == treehorn.splitter(d)