Skip to content

Commit

Permalink
US32 Implemented
Browse files Browse the repository at this point in the history
Added function and unit test for US32 to list multiple births
  • Loading branch information
kgensheimer committed Nov 11, 2018
1 parent d12116b commit a519df9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.list_deceased() #US29
self.list_living_married() #US30
self.list_living_single() #US31
self.list_multiple_births() #US32
self.list_anniversaries() #US39

if print_errors == True:
Expand Down Expand Up @@ -580,6 +581,24 @@ def list_living_single(self):
if person.age > 30 and len(person.fams) == 0 and person.deat == None:
self.add_errors_if_new("US31: {} is single and alive".format(person.name))

def list_multiple_births(self):
"""US32: This method lists all multiple births in a family"""
for fam in self.family.values():
childIDLstCopy = deepcopy(list(fam.chil))
childIDLstCopy.sort() #needs to be sorted since every time the program runs, the order of the children set changes

birthDayDict = {}
for i in range(len(childIDLstCopy)):
child = self.individuals[childIDLstCopy[i]]
if child.birt not in birthDayDict:
birthDayDict[child.birt] = 1
else:
birthDayDict[child.birt] = birthDayDict[child.birt] + 1
for key in birthDayDict:
if birthDayDict[key] > 1:
familyName = str(self.individuals[fam.husb].name).split()[-1]
self.add_errors_if_new("US32: The {} family has had {} children born at the same time".format(familyName, birthDayDict[key]))

def list_anniversaries(self):
"""US39: This method lists all upcoming anniversaries in the next 30 days"""
for fam in self.family.values():
Expand Down
10 changes: 10 additions & 0 deletions Unit_Test_Proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ def test_list_living_single(self):
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def list_multiple_births(self):
"""US32: Tests to ensure that all families who have had multiple births are listed"""
list_of_known_errors = ["US32: The /Fif/ family has had 2 children born at the same time",
"US32: The /Fif/ family has had 4 children born at the same time",
"US32: The /Fif/ family has had 6 children born at the same time",
"US32: The /Leffe/ family has had 2 children born at the same time",
"US32: The /Quick/ family has had 2 children born at the same time"]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_list_anniversaries(self):
"""US39: Tests to ensure that all anniversaries to occur in the next 30 days are listed"""
list_of_known_errors = ["US39: Art /Versity/ and Ann /Versity/ have an anniversary coming in 29 days"]
Expand Down

0 comments on commit a519df9

Please sign in to comment.