Skip to content

Commit

Permalink
US25 Unique children in families
Browse files Browse the repository at this point in the history
  • Loading branch information
timshine committed Oct 21, 2018
1 parent 457b388 commit a4b3e4d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
44 changes: 42 additions & 2 deletions Bad_GEDCOM_test_data.ged
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,37 @@
1 SEX M
1 BIRT
2 DATE 10 MAR 1961
0 NOTE US25: Family with duplicate children
0 @I68@ INDI
1 NAME Johnny /Quick/
1 SEX M
1 BIRT
2 DATE 11 JAN 1957
1 FAMS @F24@
0 @I69@ INDI
1 NAME Jayln /Slow/
1 SEX F
1 BIRT
2 DATE 10 JAN 1958
1 FAMS @F24@
0 @I70@ INDI
1 NAME Sloham /Jog/
1 SEX M
1 BIRT
2 DATE 17 JAN 1990
1 FAMC @F24@
0 @I71@ INDI
1 NAME Sloham /Jog/
1 SEX M
1 BIRT
2 DATE 17 JAN 1990
1 FAMC @F24@
0 @I72@ INDI
1 NAME Lauren /Leffe/
1 SEX F
1 BIRT
2 DATE 8 MAR 1921
1 FAMC @F18@
0 NOTE -----------------Start of the Families-------------------
0 @F1@ FAM
1 HUSB @I1@
Expand Down Expand Up @@ -566,6 +597,7 @@
2 DATE 16 MAR 1935
1 CHIL @I59@
1 CHIL @I60@
1 CHIL @I72@
0 @F19@ FAM
1 HUSB @I60@
1 WIFE @I61@
Expand All @@ -584,7 +616,7 @@
1 WIFE @I65@
1 MARR
2 DATE 11 FEB 1980
0 NOTE US24, the following families are duplicates of previous families
0 NOTE US24: the following families are duplicates of previous families
0 @F22@ FAM
1 HUSB @I57@
1 WIFE @I65@
Expand All @@ -596,4 +628,12 @@
1 MARR
2 DATE 15 MAR 2045
1 DIV
2 DATE 3 JAN 2049
2 DATE 3 JAN 2049
0 NOTE US25: Family with more than one child with same name and birthdate
0 @F24@ FAM
1 HUSB @I68@
1 WIFE @I69@
1 MARR
2 DATE 15 MAR 1980
1 CHIL @I70@
1 CHIL @I71@
13 changes: 13 additions & 0 deletions GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.no_marriage_to_descendants()
self.unique_names_and_bdays() #US23
self.unique_spouses_in_family() #US24
self.unique_children_in_family() #US25

if print_errors == True:
self.print_errors()
Expand Down Expand Up @@ -435,6 +436,18 @@ def unique_spouses_in_family(self):
else:
unique_families += [(husb_name, wife_name, family.marr)]

def unique_children_in_family(self):
"""US25: Checks to make sure that each child in a family has a unique name and birthdate"""
for ID, family in self.family.items():
unique_child_names = []
for child in family.chil:
child_name = self.individuals[child].name
child_bday = self.individuals[child].birt
if (child_name, child_bday) in unique_child_names:
self.all_errors += ["US25: There is more than one child with the name {} and birthdate {} in family {}".format(child_name, child_bday, ID)]
else:
unique_child_names += [(child_name, child_bday)]

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 @@ -169,5 +169,15 @@ def test_unique_spouses_in_family(self):
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_unique_children_in_family(self):
"""US25: Tests to ensure that there are no duplicate children within the same family
with the same name and the same birthdate"""
list_of_known_errors = [
"US25: There is more than one child with the name Lauren /Leffe/ and birthdate 1921-03-08 in family F18",
"US25: There is more than one child with the name Sloham /Jog/ and birthdate 1990-01-17 in family F24"
]
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 a4b3e4d

Please sign in to comment.