Example #1
0
def test_deep_merge_list11():
    """
    """
    a = [{'foo': 23}, {'bar': 666}]
    b = [{'foo': 33}, {'goo': 17}]
    c = _deep_merge_object(a, b)
    assert c == [{'foo': 33}, {'bar': 666, 'goo': 17}]
Example #2
0
def test_deep_merge_list10():
    """
    """
    a = [{'foo': 23}, {'bar': 666}, {'baz': 42}]
    b = [None, 'COPY', 'COPY', {'moo': 99}]
    c = _deep_merge_object(a, b)
    assert c == [{'bar': 666}, {'baz': 42}, {'moo': 99}]
Example #3
0
def test_deep_merge_list9():
    """
    """
    a = [{'foo': 23}, {'bar': 666}, {'baz': 42}]
    b = ['COPY', None, 'COPY']
    c = _deep_merge_object(a, b)
    assert c == [{'foo': 23}, {'baz': 42}]
Example #4
0
def test_deep_merge_map9():
    """
    Test replacing an existing key in a nested map.
    """
    a = {'foo': 23, 'bar': {'baz': 666}}
    b = {'bar': {'baz': 888}}
    c = _deep_merge_object(a, b)
    assert c == {'foo': 23, 'bar': {'baz': 888}}
Example #5
0
def test_deep_merge_list7():
    """
    Test partially dropping items, copying and appending items.
    """
    a = [1, 2, 3]
    b = [0, None, 'COPY', 4, 5]
    c = _deep_merge_object(a, b)
    assert c == [0, 3, 4, 5]
Example #6
0
def test_deep_merge_list5():
    """
    Test replacing a list.
    """
    a = [1, 2, 3]
    b = [None, None, None, 4, 5]
    c = _deep_merge_object(a, b)
    assert c == [4, 5]
Example #7
0
def test_deep_merge_list4():
    """
    Test expanding a list at the tail.
    """
    a = [1, 2, 3]
    b = ['COPY', 'COPY', 'COPY', 4]
    c = _deep_merge_object(a, b)
    assert c == [1, 2, 3, 4]
Example #8
0
def test_deep_merge_list3():
    """
    Test copying a list.
    """
    a = [1, 2, 3]
    b = [None, None, None]
    c = _deep_merge_object(a, b)
    assert c == []
Example #9
0
def test_deep_merge_list2():
    """
    Test copying a list.
    """
    a = [1, 2, 3]
    b = ['COPY', 'COPY', 'COPY']
    c = _deep_merge_object(a, b)
    assert c == [1, 2, 3]
Example #10
0
def test_deep_merge_list1():
    """
    Test merging two empty lists.
    """
    a = []
    b = []
    c = _deep_merge_object(a, b)
    assert c == []
Example #11
0
def test_deep_merge_map10():
    """
    Test expanding a nested map with a new key.
    """
    a = {'foo': 23, 'bar': {'baz': 666}}
    b = {'bar': {'moo': 888}}
    c = _deep_merge_object(a, b)
    assert c == {'foo': 23, 'bar': {'baz': 666, 'moo': 888}}
Example #12
0
def test_deep_merge_map7():
    """
    Test "expanding" a nested map with an empty map.
    """
    a = {'foo': 23, 'bar': {'baz': 666}}
    b = {'bar': {}}
    c = _deep_merge_object(a, b)
    assert c == {'foo': 23, 'bar': {'baz': 666}}
Example #13
0
def test_deep_merge_map6():
    """
    Test adding a new key to a map.
    """
    a = {'foo': 23}
    b = {'bar': 666}
    c = _deep_merge_object(a, b)
    assert c == {'foo': 23, 'bar': 666}
Example #14
0
def test_deep_merge_map8():
    """
    Test removing an existing key in a nested map.
    """
    a = {'foo': 23, 'bar': {'baz': 666}}
    b = {'bar': {'baz': None}}
    c = _deep_merge_object(a, b)
    assert c == {'foo': 23, 'bar': {}}
Example #15
0
def test_deep_merge_map5():
    """
    Test removing a non-existent key from a map.
    """
    a = {'foo': 23}
    b = {'bar': None}
    c = _deep_merge_object(a, b)
    assert c == a
Example #16
0
def test_deep_merge_map4():
    """
    Test removing a key from a non-empty map.
    """
    a = {'foo': 23}
    b = {'foo': None}
    c = _deep_merge_object(a, b)
    assert c == {}
Example #17
0
def test_deep_merge_map3():
    """
    Test merging a non-empty map into an empty map.
    """
    a = {}
    b = {'foo': 23}
    c = _deep_merge_object(a, b)
    assert c == b
Example #18
0
def test_deep_merge_map1():
    """
    Test merging two empty maps.
    """
    a = {}
    b = {}
    c = _deep_merge_object(a, b)
    assert c == {}
Example #19
0
def test_deep_merge_complex1():
    """
    """
    a = [{'foo': [1, 2, 3]}, {'bar': [{'baz': 666}, [4, 5, 6]]}]
    b = [{'foo': [None, 5, 'COPY', 9]}, {'bar': [{'goo': 777}, 'COPY']}]
    c = _deep_merge_object(a, b)
    assert c == [{
        'foo': [5, 3, 9]
    }, {
        'bar': [{
            'baz': 666,
            'goo': 777
        }, [4, 5, 6]]
    }]