Skip to content

Commit

Permalink
Added US29 and US30, both tests and code
Browse files Browse the repository at this point in the history
US29: Lists all deceased individuals in the GEDCOM file
US30: Lists all living married people in the GEDCOM file
  • Loading branch information
Mike-Alecci committed Nov 1, 2018
1 parent 2af78e3 commit 48e08cb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 21 deletions.
57 changes: 36 additions & 21 deletions GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,30 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.individuals = ind_dict
self.family = fam_dict
self.all_errors = errors
self.dates_before_curr() #US01
self.indi_birth_before_marriage() #US02
self.birth_before_death() #US03
self.marr_before_div() #US04
self.marr_div_before_death() #US05 & US06
self.normal_age() #US07
self.birth_before_marriage() #US08
self.dates_before_curr() #US01
self.indi_birth_before_marriage() #US02
self.birth_before_death() #US03
self.marr_before_div() #US04
self.marr_div_before_death() #US05 & US06
self.normal_age() #US07
self.birth_before_marriage() #US08
self.brith_before_death_of_parents() #US09
self.spouses_too_young() #US10
self.no_bigamy() #US11
self.parents_too_old() #US12
self.sibling_spacing() #US13
self.too_many_births()
self.too_many_siblings() #US15
self.no_marriage_to_descendants()#US17
self.no_marriage_to_siblings() #US18
self.no_marriage_to_cousin() #US19
self.creepy_aunts_and_uncles() #US20
self.correct_gender_role() #US21
self.unique_names_and_bdays() #US23
self.unique_spouses_in_family() #US24
self.unique_children_in_family() #US25
self.spouses_too_young() #US10
self.no_bigamy() #US11
self.parents_too_old() #US12
self.sibling_spacing() #US13
self.too_many_births() #US14
self.too_many_siblings() #US15
self.no_marriage_to_descendants() #US17
self.no_marriage_to_siblings() #US18
self.no_marriage_to_cousin() #US19
self.creepy_aunts_and_uncles() #US20
self.correct_gender_role() #US21
self.unique_names_and_bdays() #US23
self.unique_spouses_in_family() #US24
self.unique_children_in_family() #US25
self.list_deceased() #US29
self.list_living_married() #US30

if print_errors == True:
self.print_errors()
Expand Down Expand Up @@ -532,6 +534,19 @@ def unique_children_in_family(self):
else:
unique_child_names += [(child_name, child_bday)]

def list_deceased(self):
"""US29: This method lists all of the deceased people in the GEDCOM file"""
for person in self.individuals.values():
if person.deat != None:
self.all_errors += ["US29: {} is deceased".format(person.name)]

def list_living_married(self):
"""US30: This method lists all of the living married people in the GEDCOM file"""
for family in self.family.values():
if family.div != None:
self.add_errors_if_new("US30: {} is alive and married".format(self.individuals[family.husb].name))
self.add_errors_if_new("US30: {} is alive and married".format(self.individuals[family.wife].name))

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
20 changes: 20 additions & 0 deletions Unit_Test_Proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,25 @@ def test_unique_children_in_family(self):
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_list_deceased(self):
"""US29: Tests to ensure that all deceased individuals are listed"""
list_of_known_errors = ["US29: Future /Trunks/ is deceased","US29: James /Nicholas/ is deceased",
"US29: Jessica /Joseline/ is deceased", "US29: John /Old/ is deceased",
"US29: Johnny /James/ is deceased", "US29: Mark /Eff/ is deceased",
"US29: Peter /Tosh/ is deceased", "US29: Stevie /Wonder/ is deceased", "US29: Troy /Johnson/ is deceased"]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_list_living_married(self):
"""US30: Tests to ensure that all individuals who are alive and still married are listed"""
list_of_known_errors = ["US30: Emily /Deere/ is alive and married", "US30: Future /Trunks/ is alive and married",
"US30: Jane /Leffe/ is alive and married", "US30: Jen /Smith/ is alive and married",
"US30: Joe /Shmoe/ is alive and married", "US30: John /Leffe/ is alive and married",
"US30: Johnson /Deere/ is alive and married", "US30: Mai /Trunks/ is alive and married",
"US30: Mary /Shmoe/ is alive and married", "US30: Matt /Smith/ is alive and married",
"US30: Sammy /Johnson/ is alive and married", "US30: Troy /Johnson/ is alive and married"]
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 48e08cb

Please sign in to comment.