Skip to content

Commit

Permalink
US24 Unique family spouses
Browse files Browse the repository at this point in the history
  • Loading branch information
timshine committed Oct 21, 2018
1 parent b669e00 commit 457b388
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Bad_GEDCOM_test_data.ged
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,16 @@
1 WIFE @I65@
1 MARR
2 DATE 11 FEB 1980
0 NOTE US24, the following families are duplicates of previous families
0 @F22@ FAM
1 HUSB @I57@
1 WIFE @I65@
1 MARR
2 DATE 11 FEB 1980
0 @F23@ FAM
1 HUSB @I21@
1 WIFE @I22@
1 MARR
2 DATE 15 MAR 2045
1 DIV
2 DATE 3 JAN 2049
15 changes: 14 additions & 1 deletion GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.too_many_siblings() #US15
self.no_marriage_to_descendants()
self.unique_names_and_bdays() #US23
self.unique_spouses_in_family() #US24

if print_errors == True:
self.print_errors()
Expand Down Expand Up @@ -369,7 +370,6 @@ def sibling_spacing(self):
self.all_errors += ["US13: Siblings {} and {}'s births are only ".format(child1.name, child2.name) + str(daysApart) + " days apart"]



def too_many_births(self):
"""US14: Makes sure that no more than five siblings should be born at the same time"""
for fam in self.family.values():
Expand Down Expand Up @@ -422,6 +422,19 @@ def unique_names_and_bdays(self):
else:
names_and_bdays += [(person.name, person.birt)]

def unique_spouses_in_family(self):
"""US24: Checks to see if only one family has spouses with the same names
and marriage dates. Will indicate if there is more than one family with same spouses
and marriage date"""
unique_families = [] # input in the form (husband name, wife name, marriage date)
for family in self.family.values():
husb_name = self.individuals[family.husb].name
wife_name = self.individuals[family.wife].name
if (husb_name, wife_name, family.marr) in unique_families:
self.all_errors += ["US24: The family with spouses {} and {} married on {} occurs more than once in the GEDCOM file.".format(husb_name, wife_name, family.marr)]
else:
unique_families += [(husb_name, wife_name, family.marr)]

def add_errors_if_new(self, error):
"""This method is here to add errors to the error list if they do not occur, in order to ensure no duplicates.
Some user stories may flag duplicate errors and this method eliminates the issue."""
Expand Down
10 changes: 10 additions & 0 deletions Unit_Test_Proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,15 @@ def test_unique_names_and_bdays(self):
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_unique_spouses_in_family(self):
"""US24: Tests to ensure that there are no duplicate family entries, with the same
spouses (by name) and marriage dates"""
list_of_known_errors = [
"US24: The family with spouses Future /Trunks/ and Mai /Trunks/ married on 2045-03-15 occurs more than once in the GEDCOM file.",
"US24: The family with spouses John /Leffe/ and Ava /Leffe/ married on 1980-02-11 occurs more than once in the GEDCOM file."
]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

if __name__ == '__main__':
unittest.main(exit=False, verbosity=2)

0 comments on commit 457b388

Please sign in to comment.