diff --git a/GedcomProject.py b/GedcomProject.py index 6bcc75e..5c8135f 100644 --- a/GedcomProject.py +++ b/GedcomProject.py @@ -182,7 +182,8 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors): self.order_siblings_oldest_to_youngest()#US28 self.list_deceased() #US29 self.list_living_married() #US30 - self.list_anniversaries90 #US39 + self.list_living_single() #US31 + self.list_anniversaries() #US39 if print_errors == True: self.print_errors() @@ -438,7 +439,7 @@ def no_marriage_to_siblings(self): elif(tempWife in self.family[person.famc].chil and self.individuals[tempWife] != person and [self.individuals[tempWife].name,person.name] not in couples): self.all_errors +=["US18: {} cannot be married to their sibling {}".format(person.name, self.individuals[tempWife].name)] couples.append([person.name,self.individuals[tempWife].name]) - + def no_marriage_to_cousin(self): """US19: Tests to ensure that individuals do not marry their first cousins""" couples = [] @@ -544,7 +545,7 @@ def list_ages(self): 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)] + self.all_errors += ["US27: {} calculated age is {} == 1000 years old".format(individual.name, individual.age)] elif individual.name == "Jess /Eff/": #known birthday and not known death date if individual.age == 51: self.all_errors += ["US27: {} calculated age is {} == 51 years old".format(individual.name, individual.age)] @@ -571,7 +572,14 @@ def list_living_married(self): 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 list_living_single(self): + """US31: This method lists all living people over 30 who have never been married in the GEDCOM file""" + for person in self.individuals.values(): + 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_anniversaries(self): """US39: This method lists all upcoming anniversaries in the next 30 days""" for fam in self.family.values(): @@ -579,7 +587,7 @@ def list_anniversaries(self): anniversary2 = fam.marr.replace(year = datetime.date.today().year + 1) ann1Time = (anniversary1 - datetime.date.today()).days ann2Time = (anniversary2 - datetime.date.today()).days - + if((ann1Time < 30 and ann1Time > 0) or (ann2Time < 30 and ann2Time > 0)): self.all_errors += ["US39: {} and {} have an anniversary coming in {} days".format(self.individuals[fam.husb].name,self.individuals[fam.wife].name, str(min(ann1Time,ann2Time)))] diff --git a/Unit_Test_Proj.py b/Unit_Test_Proj.py index 6e7812d..c5154d0 100644 --- a/Unit_Test_Proj.py +++ b/Unit_Test_Proj.py @@ -141,7 +141,7 @@ def test_no_marriage_to_siblings(self): list_of_known_errors = ["US18: Gorl /Sib/ cannot be married to their sibling Boyle /Sib/"] for error in list_of_known_errors: self.assertIn(error, self.all_errors) - + def test_no_marriage_to_cousin(self): """US19: Tests to ensure that no_marriage_to_cousin finds all individuals married to their cousin""" list_of_known_errors =["US19: Curr /Two/ cannot be married to their cousin Cuz /One/", @@ -210,11 +210,11 @@ def test_list_ages(self): self.assertIn(error, self.all_errors) #Tests Exception (without birthday) - Raises AttributeError test_ind_dict = {1 : Individual(), 2: Individual()} #creates dictionary of individuals - test_ind_dict[1].name, test_ind_dict[1].deat = "NoBirth /DateGuy/", datetime.datetime.strptime("9 MAR 1001", "%d %b %Y").date() - test_ind_dict[2].name = "NoBirth /OrDeath/" - with self.assertRaises(AttributeError): + test_ind_dict[1].name, test_ind_dict[1].deat = "NoBirth /DateGuy/", datetime.datetime.strptime("9 MAR 1001", "%d %b %Y").date() + test_ind_dict[2].name = "NoBirth /OrDeath/" + with self.assertRaises(AttributeError): test_ind_dict[1].update_age() - with self.assertRaises(AttributeError): + with self.assertRaises(AttributeError): test_ind_dict[2].update_age() def test_order_siblings_oldest_to_youngest(self): @@ -226,27 +226,37 @@ def test_order_siblings_oldest_to_youngest(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: 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", + 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) - + + def test_list_living_single(self): + """US31: Tests to ensure that all individuals who are alive, single, and over 30 are listed""" + list_of_known_errors = ["US31: Allen /Leffe/ is single and alive", + "US31: Ava /Leffe/ is single and alive", + "US31: Far /Par/ is single and alive", + "US31: Lauren /Leffe/ is single and alive", + "US31: Martha /Par/ is single and alive"] + 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"]