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