Beispiel #1
0
def test_simple_negative_join_with():
    d1 = {'a': 'sub_tree1', 'b': 'hello1'}
    d2 = {'b': 'sub_tree', 'c': 'hello'}
    eq_(
        join_with(d1, lambda x, y: isinstance(y, str), d2),
        d1,
        "Not join different trees"
    )
Beispiel #2
0
def test_simple_join_with_complex_condition():
    d1 = {'a': 'sub_tree', 'b': 'hello'}
    d2 = {'b': 'sub_tree', 'c': 'hello'}
    eq_(
        join_with(d1, lambda x, y: x == 'b' and isinstance(y, str), d2),
        {'a': d2, 'b': 'hello'},
        "Not join different trees"
    )
Beispiel #3
0
def test_simple_join_with():
    d1 = {'a': 'sub_tree', 'b': 'hello'}
    d2 = {'b': 'sub_tree', 'c': 'hello'}
    eq_(
        join_with(d1, lambda x, y: isinstance(y, str), d2),
        {'a': d2, 'b': d2},
        "Make complex tree if has common keys"
    )
Beispiel #4
0
def construction_of_family_tree():
    jones = {
        'father': "Sergey",
        'mather': "Irina",
        'child': "Konstantin"
    }

    jones_second = {
        'father': "Konstantin",
        'mother': "Tanya",
        'child': None
    }

    print join_with(
        jones,
        lambda k, v: k == 'father' and isinstance(v, basestring),
        jones_second
    )