Skip to content

Commit

Permalink
US14 Test and Function, also fixed US15 unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
kgensheimer committed Oct 15, 2018
1 parent e923ee6 commit 73f5983
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Bad_GEDCOM_test_data.ged
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
1 NAME Three /Fif/
1 SEX F
1 BIRT
2 DATE 1 JAN 2000
2 DATE 1 JAN 2002
1 FAMC @F14@
0 @I33@ INDI
1 NAME Four /Fif/
Expand Down
22 changes: 19 additions & 3 deletions GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __init__(self, ind_dict, fam_dict, print_errors):
self.no_bigamy() #US11
self.parents_too_old() #US12
self.sibling_spacing() #US13
#Call US14 Here
self.too_many_births()
self.too_many_siblings() #US15
self.no_marriage_to_descendants()

Expand Down Expand Up @@ -364,13 +364,29 @@ def sibling_spacing(self):

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():
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] > 5:
familyName = str(self.individuals[fam.husb].name).split()[-1]
self.all_errors += ["US14: The {} family has more than five children born at the same time".format(familyName)]


def too_many_siblings(self):
"""US15: Tests to ensure that there are fewer than 15 siblings in a family"""
for fam in self.family.values():
if len(fam.chil)>=15:
self.all_errors+=["US15: The {} family has 15 or more siblings".format(self.individuals[fam.husb].fams)]
familyName = str(self.individuals[fam.husb].name).split()[-1]
self.all_errors+=["US15: The {} family has 15 or more siblings".format(familyName)]

def descendants_help(self, initial_indi, current_indi ):
"""Recursive helper for US17"""
Expand Down
8 changes: 7 additions & 1 deletion Unit_Test_Proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def test_parents_too_old(self):
self.assertIn(error, self.all_errors)

def test_sibling_spacing(self):
"""US13: Tests thatbirth dates of siblings should be more than 8 months apart or less than 2 days apart
(twins may be born one day apart, e.g. 11:59 PM and 12:02 AM the following calendar day)"""
list_of_known_errors = ["US13: Siblings One /Fif/ and Thirteen /Fif/'s births are only 5 days apart",
"US13: Siblings Two /Fif/ and Thirteen /Fif/'s births are only 5 days apart",
"US13: Siblings Three /Fif/ and Thirteen /Fif/'s births are only 5 days apart",
Expand All @@ -125,7 +127,11 @@ def test_sibling_spacing(self):
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

#INSERT US14 TEST HERE
def test_too_many_births(self):
"""US14: Tests that no more than five siblings should be born at the same time"""
list_of_known_errors = ["US14: The /Fif/ family has more than five children born at the same time"]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_too_many_siblings(self):
"""US15: Test: Makes sure too_many_siblings function works properly"""
Expand Down

0 comments on commit 73f5983

Please sign in to comment.