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)
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)
def test_delete_ref_duplicates_with_empty_dict(): assert {} == delete_ref_duplicates({})
def test_delete_ref_duplicates_with_simple_object(): data = {'id': '123', 'name': 'foo', 'type': 'bar', 'values': ['a', 'b']} assert data == delete_ref_duplicates(data)
def test_delete_ref_duplicates_with_none(): assert delete_ref_duplicates(None) is None