Skip to content

Commit

Permalink
US27 Checks Age Calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
timshine committed Nov 2, 2018
1 parent 25cee24 commit 54c7ce0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Bad_GEDCOM_test_data.ged
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
1 BIRT
2 DATE 8 APR 1007
1 DEAT
2 DATE 10 JUL 2007
2 DATE 9 APR 2007
1 FAMS @F4@
0 @I10@ INDI
1 NAME Jackie /Old/
Expand Down
10 changes: 10 additions & 0 deletions GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.unique_names_and_bdays() #US23
self.unique_spouses_in_family() #US24
self.unique_children_in_family() #US25
self.list_ages() #US27
self.list_deceased() #US29
self.list_living_married() #US30

Expand Down Expand Up @@ -534,6 +535,15 @@ def unique_children_in_family(self):
else:
unique_child_names += [(child_name, child_bday)]

def list_ages(self):
"""US27: This method ensures that the people are being listed with proper ages in the table
This simply ensures the calculation for age correctly by checking one person's name
John /Old/ was born in 1007 and died in 2007"""
for individual in self.individuals.values():
if individual.name == 'John /Old/':
if individual.age == 1000:
self.all_errors += ["US27: {} calculated age is {} == 1000 years old".format(individual.name, individual.age)]

def list_deceased(self):
"""US29: This method lists all of the deceased people in the GEDCOM file"""
for person in self.individuals.values():
Expand Down
9 changes: 9 additions & 0 deletions Unit_Test_Proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def test_unique_children_in_family(self):
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_list_ages(self):
"""US27: Tests to ensure that people's ages are properly being calculated when listed in
the GEDCOM table"""
list_of_known_errors = [
"US27: John /Old/ calculated age is 1000 == 1000 years old"
]
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",
Expand Down

0 comments on commit 54c7ce0

Please sign in to comment.