예제 #1
0
def test_delete_ref_duplicates_with_object_containing_duplicate_refs():
    data = {
        'id':
        '123',
        'name':
        'foo',
        'type':
        'bar',
        'refs': [{
            'id': '123',
            'type': 'baz'
        }, {
            'id': '123',
            'type': 'baz'
        }, {
            'id': '234',
            'type': 'baz'
        }, {
            'id': '234',
            'type': 'baz'
        }, {
            'id': '234',
            'type': 'foo'
        }]
    }
    assert {
        'id':
        '123',
        'name':
        'foo',
        'type':
        'bar',
        'refs': [{
            'id': '123',
            'type': 'baz'
        }, {
            'id': '234',
            'type': 'baz'
        }, {
            'id': '234',
            'type': 'foo'
        }]
    } == delete_ref_duplicates(data)
예제 #2
0
def test_delete_ref_duplicates_with_object_containing_duplicate_refs_in_nested_object(
):
    data = {
        'id': '123',
        'name': 'foo',
        'type': 'bar',
        'children': {
            'refs': [{
                'id': '123',
                'type': 'baz'
            }, {
                'id': '123',
                'type': 'baz'
            }, {
                'id': '234',
                'type': 'baz'
            }, {
                'id': '234',
                'type': 'baz'
            }, {
                'id': '234',
                'type': 'foo'
            }]
        }
    }
    assert {
        'id': '123',
        'name': 'foo',
        'type': 'bar',
        'children': {
            'refs': [{
                'id': '123',
                'type': 'baz'
            }, {
                'id': '234',
                'type': 'baz'
            }, {
                'id': '234',
                'type': 'foo'
            }]
        }
    } == delete_ref_duplicates(data)
예제 #3
0
def test_delete_ref_duplicates_with_empty_dict():
    assert {} == delete_ref_duplicates({})
예제 #4
0
def test_delete_ref_duplicates_with_simple_object():
    data = {'id': '123', 'name': 'foo', 'type': 'bar', 'values': ['a', 'b']}
    assert data == delete_ref_duplicates(data)
예제 #5
0
def test_delete_ref_duplicates_with_none():
    assert delete_ref_duplicates(None) is None