Skip to content

Commit

Permalink
Fix to merge function
Browse files Browse the repository at this point in the history
Will absorb gender of 'other' when self has none.
  • Loading branch information
ajparsons authored and mhl committed Jan 31, 2018
1 parent 75ee479 commit 37b644c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions popolo_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def absorb(self,other):
for n in other.other_names:
if n["name"] not in our_names:
self.other_names.append(n)

if not self.gender and other.gender:
self.gender = other.gender

class Organization(PopoloObject):

Expand Down
4 changes: 3 additions & 1 deletion tests/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def test_merge(self):
"""
full_attributes = {"id": "person1",
"email": "test@madeup.com",
"gender": "male",
"honorific_prefix": "Dr",
"honorific_suffix": "MBe",
"image": "blahblah.jpg",
Expand All @@ -79,6 +78,7 @@ def test_merge(self):
}

reduced_attributes = {"id": "4435435",
"gender": "male",
"name": "Indiana Jones",
"other_names": [{"name":"Indiana Walton Jones"}],
}
Expand Down Expand Up @@ -120,6 +120,8 @@ def test_merge(self):
assert other_person.id == "person1"
assert new_person.property == "123 fake street"
assert other_person.property == "123 fake street"
assert new_person.gender == "male"
assert other_person.gender == "male"
assert "Indiana Walton Jones" in [x["name"] for x in new_person.other_names]
assert "Indiana Walton Jones" not in [x["name"] for x in original.other_names]

Expand Down

0 comments on commit 37b644c

Please sign in to comment.