Example #1
0
 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)
Example #2
0
def test_keep_both_ids(old, new, expected):
    assert merge_people(old, new, keep_both_ids=True) == expected
Example #3
0
def test_list_merge(old, new, expected):
    # note that keep doesn't matter for these
    assert merge_people(old, new, None) == expected
Example #4
0
def test_merge_conflict():
    with pytest.raises(MergeConflict):
        merge_people({"name": "A"}, {"name": "B"})
Example #5
0
def test_simple_merge(old, new, keep, expected):
    assert merge_people(old, new, keep) == expected
Example #6
0
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
Example #7
0
def test_merge_conflict():
    with pytest.raises(MergeConflict):
        merge_people({'name': 'A'}, {'name': 'B'})