def merge(self, other): "Merge differences from the other PersonFile into this one" custom_merges = { 'contact_details': self.merge_contact_details, 'roles': self.merge_roles, 'sources': self.replace, 'links': self.replace, 'party': self.merge_parties, } self.data = merge_people(self.data, other.data, keep_on_conflict='new', custom_merges=custom_merges)
def test_keep_both_ids(old, new, expected): assert merge_people(old, new, keep_both_ids=True) == expected
def test_list_merge(old, new, expected): # note that keep doesn't matter for these assert merge_people(old, new, None) == expected
def test_merge_conflict(): with pytest.raises(MergeConflict): merge_people({"name": "A"}, {"name": "B"})
def test_simple_merge(old, new, keep, expected): assert merge_people(old, new, keep) == expected
def test_merge_extras(): # replace was adding a key like extras._internal_id old = {"extras": {"_internal_id": 123}} new = {} expected = old.copy() assert merge_people(new, old) == expected
def test_merge_conflict(): with pytest.raises(MergeConflict): merge_people({'name': 'A'}, {'name': 'B'})