def test_user_stories(self): dir_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..')) directory_path_us38 = f'{dir_path}/data/us38.ged' directory_path_us39 = f'{dir_path}/data/us39.ged' individuals_us38, families_us38 = gedcom_file_parser(directory_path_us38) individuals_us39, families_us39 = gedcom_file_parser(directory_path_us39) print_list_upcoming_birthdays(individuals_us38, use_todays_date=False) print_list_upcoming_anniversaries(individuals_us39, families_us39, use_todays_date=False) # Expected Result for US38 us38_pt = PrettyTable(field_names=["ID", "Name"]) us38_pt.add_row(['@I2@','Angelo /Rose/']) us38_pt.add_row(['@I4@','Phil /Evans/']) us38_pt.add_row(['@I6@','Sheila /Evans/']) us38_str = "US38: List: The following individuals have upcoming birthdays within 30 days!\n" + str(us38_pt) self.assertEqual(list_upcoming_birthdays(individuals_us38, use_todays_date=False), us38_str) #US39 Expected Results us39_pt = PrettyTable(field_names=["Wife ID", "Wife Name", "Husband ID", 'Husband Name']) us39_pt.add_row(['@I6@', 'Sheila /Evans/', '@I4@', 'Phil /Evans/']) us39_str = "US39: List: The following couples have upcoming anniversaries within 30 days!\n" + str(us39_pt) self.assertEqual(list_upcoming_anniversaries(individuals_us39, families_us39, use_todays_date=False), us39_str)
def test_us36_us37(self): """ Test for US36 and US37""" # Test with GEDCOM individual @I10@ dir_abs_path_us36_us37 = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path_us36_us37 = f"{dir_abs_path_us36_us37}/data/us36_37.ged" ind, fam = gedcom_file_parser(directory_path_us36_us37) ind = print_individuals_pretty_table(ind, True) fam = print_families_pretty_table(ind, fam, True) # Expected Result for US36 us36_pt = PrettyTable(field_names=["ID", "Name", "Date of Death"]) us36_pt.add_row(['@I1@', 'Tristin /Evans/', '16 Jul 2019']) us36_str = str(us36_pt) # Expected Result for US37 us37_pt = PrettyTable(field_names=["ID", "Name", "Relation"]) us37_pt.add_row(['@I2@', 'Angelo /Rose/', 'Husband']) us37_pt.add_row(['@I6@', 'Emma /Rose/', 'Descendant']) us37_str = str(us37_pt) error_chk = (us36_str, us37_str) self.assertEqual(us36(ind, fam, True), error_chk) return None
def test_user_stories(self): dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path = f'{dir_path}/data/Sprint2test.ged' individuals, families = gedcom_file_parser(directory_path) #US11 Test capturedOutput = io.StringIO() sys.stdout = capturedOutput check_bigamy(individuals, families) sys.stdout = sys.__stdout__ self.assertEqual( capturedOutput.getvalue(), 'ANOMOLY: INDIVIDUAL: US11: @I4@: Bigamy detected: Robert Evans married to multiple spouses at the same time\nANOMOLY: INDIVIDUAL: US11: @I5@: Bigamy detected: Angelo Rose married to multiple spouses at the same time\n' ) print(capturedOutput.getvalue()) #US12 Test capturedOutput2 = io.StringIO() sys.stdout = capturedOutput2 check_parents_not_too_old(individuals, families) sys.stdout = sys.__stdout__ self.assertEqual( capturedOutput2.getvalue(), 'ANOMOLY: FAMILY: US12: @F2@: Parents are too old: Parent(s) were greater than 65 years old when child was born\n' ) print(capturedOutput2.getvalue())
def test_user_stories(self): dir_abs_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path = f"{dir_abs_path}/data/US07_US08_test_file.ged" individuals, families = gedcom_file_parser(directory_path) # US07 Test capturedOutput = io.StringIO() sys.stdout = capturedOutput check_150_years_age(individuals) sys.stdout = sys.__stdout__ self.assertEqual( capturedOutput.getvalue(), 'ERROR: INDIVIDUAL: US07: @I3@: More than 150 years old - Birth date 19 May 0268\nERROR: INDIVIDUAL: US07: @I9@: More than 150 years old at death - Birth date 17 Nov 0301: Death date 15 Nov 0560\n' ) print(capturedOutput.getvalue(), "\n") #US08 Test capturedOutput2 = io.StringIO() sys.stdout = capturedOutput2 check_birth_before_marriage_of_parents(families, individuals) sys.stdout = sys.__stdout__ self.assertEqual( capturedOutput2.getvalue(), 'ANOMOLY: FAMILY: US08: @F1@: Child @I3@ born 19 May 0268 before marriage on 08 Aug 0271\nANOMOLY: FAMILY: US08: @F1@: Child @I4@ born 13 Nov 0267 before marriage on 08 Aug 0271\nANOMOLY: FAMILY: US08: @F1@: Child @I5@ born 15 Oct 0265 before marriage on 08 Aug 0271\nANOMOLY: FAMILY: US08: @F2@: Child @I9@ born 17 Nov 0301 before marriage on 15 Jan 0304\nANOMOLY: FAMILY: US08: @F3@: Child @I7@ born 05 Sep 0287 after divorce on 18 Nov 0285\n' ) print(capturedOutput2.getvalue(), "\n")
def test_print_duplicate_ids(self): dir_abs_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..')) directory_path = f"{dir_abs_path}/data/sprint3userstorytest.ged" individuals, families, duplicate_ids = gedcom_file_parser(directory_path, True) expected_error_message = ["US22: ERROR: Duplicate individual id: @I20@"] result = print_duplicate_ids(duplicate_ids) self.assertEqual(duplicate_ids, ['@I20@']) self.assertEqual(expected_error_message, result)
def test_us16(self): dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) individuals, families = gedcom_file_parser(f"{dir_path}/data/us16.ged") expected_result = [ "US16: Error: All males in family @F1@, do not have same last name" ] result = us16(individuals, families) self.assertEqual(result, expected_result)
def test_birth_before_parents_death(self): dir_abs_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path = f"{dir_abs_path}/data/sprint3userstorytest.ged" individuals, families = gedcom_file_parser(directory_path) result = birth_before_parents_death(individuals, families) expected_result = [ 'ERROR: US09: @F1@: Husband died before the birth of his child', 'ERROR: US09: @F1@ Wife died before the birth of her child' ] self.assertEqual(result, expected_result)
def test_us31(self): dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) individuals, families = gedcom_file_parser( f"{dir_path}/data/sprint3userstorytest.ged") print_individuals_pretty_table(individuals, False) print_families_pretty_table(individuals, families, False) expected_result = ['@I5@'] result = us31(individuals, families) self.assertEqual(result, expected_result)
def test_us26(self): dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) individuals, families = gedcom_file_parser(f"{dir_path}/data/us26.ged") expected_result = [ 'US26: Error: individual spouse with id @I1@ not available in family @F1@', 'US26: Error: No entry for family id @F4@ available', 'US26: Error: No entry for family id @F4@ available', 'US26: Error: Husband in family @F5@ is not listed as spouse in individual record @I2@', 'US26: Error: Wife in family @F5@ is not listed as spouse in individual record @I9@' ] result = us26(individuals, families) self.assertEqual(result, expected_result)
def test_us21(self): dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) individuals, families = gedcom_file_parser( f"{dir_path}/data/sprint3userstorytest.ged") #print_individuals_pretty_table(individuals, False) #print_families_pretty_table(families, individuals, False) expected_result = [ "US21: Error: Family @F4@ does not have a male husband." ] result = us21(individuals, families) self.assertEqual(result, expected_result)
def test_user_stories(self): dir_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path_us29 = f'{dir_path}/data/us29.ged' directory_path_us30 = f'{dir_path}/data/us30.ged' individuals_us29, families_us29 = gedcom_file_parser( directory_path_us29) individuals_us30, families_us30 = gedcom_file_parser( directory_path_us30) print_pretty_table(directory_path_us29) print_pretty_table(directory_path_us30) # Expected Result for US29 us29_pt = PrettyTable(field_names=["ID", "Name"]) us29_pt.add_row(['@I7@', 'Peter /Evans/']) us29_pt.add_row(['@I10@', 'Darren /Johnson/']) us29_str = "US29: List: The following individuals are deceased in the family\n" + str( us29_pt) self.assertEqual(list_deceased(individuals_us29), us29_str) #US30 Expected Results us30_pt = PrettyTable(field_names=[ "Family ID", "Husband ID", "Husband Name", "Wife ID", "Wife Name" ]) us30_pt.add_row( ['@F1@', '@I5@', 'Angelo /Rose/', '@I1@', 'Tristin /Evans/']) us30_pt.add_row( ['@F2@', '@I2@', 'Phil /Evans/', '@I3@', 'Sheila /Lynn/']) us30_pt.add_row( ['@F4@', '@I11@', 'David /Lynn/', '@I12@', 'Victoria /Taylor/']) us30_str = "US30: List: The following lists living married couples by family\n" + str( us30_pt) self.assertEqual(list_living_married(individuals_us30, families_us30), us30_str)
def test_us34(self): """ Test for US34""" # Test with GEDCOM family @F1@ dir_abs_path_us34 = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path_us34 = f"{dir_abs_path_us34}/data/us34.ged" ind, fam = gedcom_file_parser(directory_path_us34) ind = print_individuals_pretty_table(ind, True) fam = print_families_pretty_table(ind, fam, True) fam_id = '@F1@' error_chk = [True, False] self.assertEqual(us34(ind, fam, fam_id, True), error_chk) return None
def setUp(self): """ Class setup with assignment of self.individuals and self.families """ # Assign directory path variables to individual gedcom files to test each user story as needed for Sprint 3 Implementation # Run print_pretty_table function with specialized directory path to create indivduals and families dictionaries unique to the user story that will be tested self.dir_abs_path = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) self.directory_path = f"{self.dir_abs_path}/data/AWFStest.ged" self.individuals, self.families = gedcom_file_parser( self.directory_path) self.individuals = print_individuals_pretty_table( self.individuals, True) self.families = print_families_pretty_table(self.individuals, self.families, True) return super().setUp()
def test_us35(self): """ Test for US35""" # Test with GEDCOM Individual @I6@ dir_abs_path_us35 = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) directory_path_us35 = f"{dir_abs_path_us35}/data/us35.ged" ind, fam = gedcom_file_parser(directory_path_us35) ind = print_individuals_pretty_table(ind, True) fam = print_families_pretty_table(ind, fam, True) # Expected Result for US35 us35_pt = PrettyTable(field_names=["ID", "Name", "Date of Birth"]) us35_pt.add_row(['@I6@', 'Emma /Rose/', '17 Jul 2019']) us35_str = str(us35_pt) error_chk = us35_str self.assertEqual(us35(ind, True), error_chk) return None
def test_user_stories(self): directory_path = '/Users/saranshahlawat/Desktop/Stevens/Semesters/Summer 2019/SSW-555/project/GEDCOM/project3/data/US07_US08_test_file.ged' individuals, families = gedcom_file_parser(directory_path) print_pretty_table(directory_path) #US07 Test capturedOutput = io.StringIO() sys.stdout = capturedOutput check_150_years_age(individuals) sys.stdout = sys.__stdout__ self.assertEqual( capturedOutput.getvalue(), 'ERROR: INDIVIDUAL: US07: @I3@: More than 150 years old - Birth date 19 May 0268\nERROR: INDIVIDUAL: US07: @I9@: More than 150 years old at death - Birth date 17 Nov 0301: Death date 15 Nov 0560\n' ) #US08 Test capturedOutput2 = io.StringIO() sys.stdout = capturedOutput2 check_birth_before_marriage_of_parents(families, individuals) sys.stdout = sys.__stdout__ self.assertEqual( capturedOutput2.getvalue(), 'ANOMOLY: FAMILY: US08: @F3@: Child @I7@ born 05 Sep 0287 before marriage on 16 Jun 0280\nANOMOLY: FAMILY: US08: @F3@: Child @I7@ born 05 Sep 0287 after divorce on 18 Nov 0285\n' )