def test_US17_2family(self): # should get 2 matches # Adding Lorraine as a child of Frank's first marriage self.indMap["I12"] = { "NAME": "Lorraine/Dunphy/", "SEX": "F", "BIRT": [1, 1, 1965], "FAMS": ["F8", "F7"], "AGE": 55, "INDI": "I12" } self.famMap["F7"] = { "HUSB": ["I11"], "WIFE": ["I13"], "CHIL": ["I7", "I12"], "MARR": [1, 1, 1965], "NOTE": "FRANK/GRACE FAMILY", "FAM": "F7" } self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us17_no_marr2child(self.parentId2Children) ret = self.logger.get_logs() self.assertEqual(len(ret), 2, "Did not get the expected results")
def test_US18_half_sibling_text(self): # testing half sibling self.famMap["F1"] = { "HUSB": ["I1"], "WIFE": ["I2"], "CHIL": ["I10", "I1"], "MARR": [1, 1, 2009], "NOTE": "JAY/GLORIA FAMILY", "FAM": "F1" } self.famMap["F3"] = { "HUSB": ["I8"], "WIFE": ["I2"], "CHIL": ["I9", "I2"], "MARR": [1, 1, 1995], "DIV": [1, 1, 2006], "NOTE": "JAVIER/GLORIA", "FAM": "F3" } self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us18_no_siblingmarriages(self.parentId2Children) ret = self.logger.get_logs() str1 = "F1 has siblings as parents: ['I1', 'I2']" str2 = "F4 has siblings as parents: ['I4', 'I5']" expected_ret = [('Error', 'Family', 18, str1), ('Error', 'Family', 18, str2)] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US39_2DatesUpcomingLen(self): # should get 2 matches self.logger.clear_logs() expected_ret = [] for id, fam in self.famMap.items(): if id == "F10": dt = datetime.date.today() + datetime.timedelta(days=30) dtstr = 'FAMILY (F10) has an upcoming anniversary: ' + str( dt.month) + '/' + str(dt.day) + '/' + str(dt.year) expected_ret.append(('Info', 'Family', 39, dtstr)) elif id == "F4": dt = datetime.date.today() + datetime.timedelta(days=1) dtstr = 'FAMILY (F4) has an upcoming anniversary: ' + str( dt.month) + '/' + str(dt.day) + '/' + str(dt.year) expected_ret.append(('Info', 'Family', 39, dtstr)) else: # overwrite all Marriages as one day ago dt = datetime.date.today() - datetime.timedelta(days=1) fam["MARR"] = [dt.day, dt.month, dt.year] spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us39_upcoming_anniversaries() ret = self.logger.get_logs() self.assertEqual(len(ret), 2, "Did not get the expected results")
def test_US39_2DatesUpcoming(self): # should get 2 matches self.logger.clear_logs() expected_ret = [] for id, fam in self.famMap.items(): if id == "F10": dt = datetime.date.today() + datetime.timedelta(days=30) dtstr = 'FAMILY (F10) has an upcoming anniversary: ' + str( dt.month) + '/' + str(dt.day) + '/' + str(dt.year) expected_ret.append(('Info', 'Family', 39, dtstr)) elif id == "F4": dt = datetime.date.today() + datetime.timedelta(days=1) dtstr = 'FAMILY (F4) has an upcoming anniversary: ' + str( dt.month) + '/' + str(dt.day) + '/' + str(dt.year) expected_ret.append(('Info', 'Family', 39, dtstr)) else: dt = datetime.date.today() - datetime.timedelta(days=1) fam["MARR"] = [dt.day, dt.month, dt.year] spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us39_upcoming_anniversaries() # should find 1 match and the following expected result ret = self.logger.get_logs() self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US17_2family_text(self): # should find 2 matches and the following expected result # Adding Lorraine as a child of Frank's first marriage self.indMap["I12"] = { "NAME": "Lorraine/Dunphy/", "SEX": "F", "BIRT": [1, 1, 1965], "FAMS": ["F8", "F7"], "AGE": 55, "INDI": "I12" } self.famMap["F7"] = { "HUSB": ["I11"], "WIFE": ["I13"], "CHIL": ["I7", "I12"], "MARR": [1, 1, 1965], "NOTE": "FRANK/GRACE FAMILY", "FAM": "F7" } self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us17_no_marr2child(self.parentId2Children) ret = self.logger.get_logs() str1 = "F8: My spouse (I12) is one of my children: Parent (I11), Children (['I7', 'I12'])" str2 = "F11: My spouse (I26) is one of my children: Parent (I27), Children (['I26'])" expected_ret = [('Error', 'Family', 17, str1), ('Error', 'Family', 17, str2)] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US18_half_sibling(self): # should get 2 matches # testing half sibling self.famMap["F1"] = { "HUSB": ["I1"], "WIFE": ["I2"], "CHIL": ["I10", "I1"], "MARR": [1, 1, 2009], "NOTE": "JAY/GLORIA FAMILY", "FAM": "F1" } self.famMap["F3"] = { "HUSB": ["I8"], "WIFE": ["I2"], "CHIL": ["I9", "I2"], "MARR": [1, 1, 1995], "DIV": [1, 1, 2006], "NOTE": "JAVIER/GLORIA", "FAM": "F3" } self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us18_no_siblingmarriages(self.parentId2Children) ret = self.logger.get_logs() self.assertEqual(len(ret), 2, "Did not get the expected results")
def test_FiveorMoreMultBirthsinOneFamiy(self): # add in a set of sixtuplets to family 4 - so they have triplets and twins for i in range(31, 36): self.indMap["I" + str(i)] = { "NAME": "I" + str(i) + "/Tucker-Pritchett/", "SEX": "F", "BIRT": [1, 5, 2019], "FAMC": ["F4"], "NOTE": "Adding Multiple Birth Child to Family F4", "INDI": "I" + str(i) } self.famMap["F4"]["CHIL"].append("I" + str(i)) # user story 14 self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us14_mult_births() ret = self.logger.get_logs() self.assertEqual(len(ret), 0, "Did not get the expected results") expected_ret = [] self.assertListEqual(expected_ret, ret, "Expected Return does not match") # user story 32 self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us32_mult_births() ret = self.logger.get_logs() self.assertEqual(len(ret), 3, "Did not get the expected results") expected_ret = [ ('Warning', 'Family', 32, 'F4 has 3 children with the same birthday (4/1/2020): I28, I29, I30' ), ('Warning', 'Family', 32, 'F4 has 5 children with the same birthday (5/1/2019): I31, I32, I33, I34, I35' ), ('Warning', 'Family', 32, 'F10 has 2 children with the same birthday (5/8/2019): I22, I23') ] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_ThreeOrMore(self): # should get the following families with multiple births of 3 or more self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._mult_births(14, 3) ret = self.logger.get_logs() self.assertEqual(len(ret), 1, "Did not get the expected results")
def test_US16_2family(self): # should get 1 match self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us16_male_last_names() ret = self.logger.get_logs() self.assertEqual(len(ret), 2, "Did not get the expected results")
def test_US18_1family(self): # should to get 1 match self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us18_no_siblingmarriages(self.parentId2Children) ret = self.logger.get_logs() self.assertEqual(len(ret), 1, "Did not get the expected results")
def test_US15_FiveOrMore(self): # should get zero family with 5 or more siblings self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._sibling_count(5) ret = self.logger.get_logs() self.assertEqual(len(ret), 0, "Did not get the expected results")
def test_US15_DefaultCount(self): # should return 10 families with siblings self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._sibling_count() ret = self.logger.get_logs() self.assertEqual(len(ret), 10, "Did not get the expected results")
def test_divBeforeDeat(self): fam1 = { "FAM": "F1", "HUSB": ["I1", "I2"], "WIFE": [], "DIV": [1, 1, 2020] } fam2 = { "FAM": "F1", "HUSB": [], "WIFE": ["I1", "I2"], "DIV": [1, 1, 2020] } fam3 = { "FAM": "F1", "HUSB": ["I1"], "WIFE": ["I2"], "DIV": [1, 1, 2020] } fam4 = { "FAM": "F1", "HUSB": ["I1"], "WIFE": ["I2"], "DIV": [1, 1, 2008] } self.record.clear_logs() checker1 = spouseCrossChecker(self.record, fam1, self.individuals) checker1.us06_divBeforeDeat() self.assertEqual(len(self.record.get_logs()), 1) checker2 = spouseCrossChecker(self.record, fam2, self.individuals) checker2.us06_divBeforeDeat() self.assertEqual(len(self.record.get_logs()), 2) checker3 = spouseCrossChecker(self.record, fam3, self.individuals) checker3.us06_divBeforeDeat() self.assertEqual(len(self.record.get_logs()), 3) checker4 = spouseCrossChecker(self.record, fam4, self.individuals) checker4.us06_divBeforeDeat() self.assertEqual(len(self.record.get_logs()), 3)
def test_marr14(self): fam1 = { "FAM": "F1", "HUSB": ["I1", "I2"], "WIFE": [], "MARR": [1, 1, 1988] } fam2 = { "FAM": "F1", "HUSB": [], "WIFE": ["I1", "I2"], "MARR": [1, 1, 1988] } fam3 = { "FAM": "F1", "HUSB": ["I1"], "WIFE": ["I2"], "MARR": [1, 1, 1988] } fam4 = { "FAM": "F1", "HUSB": ["I1"], "WIFE": ["I2"], "MARR": [1, 1, 2008] } self.record.clear_logs() checker1 = spouseCrossChecker(self.record, fam1, self.individuals) checker1.us10_marrAfter14() self.assertEqual(len(self.record.get_logs()), 1) checker2 = spouseCrossChecker(self.record, fam2, self.individuals) checker2.us10_marrAfter14() self.assertEqual(len(self.record.get_logs()), 2) checker3 = spouseCrossChecker(self.record, fam3, self.individuals) checker3.us10_marrAfter14() self.assertEqual(len(self.record.get_logs()), 3) checker4 = spouseCrossChecker(self.record, fam4, self.individuals) checker4.us10_marrAfter14() self.assertEqual(len(self.record.get_logs()), 3)
def test_US15_FourOrMoreText(self): # should get 1 family with 4 or more siblings expected_ret = [('Warning', 'Family', 15, 'Family F4 has 4 or more children (4)')] self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._sibling_count(4) ret = self.logger.get_logs() self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US15_FiveOrMoreText(self): # should get zero family with 5 or more siblings expected_ret = [] self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._sibling_count(5) ret = self.logger.get_logs() self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US16_nomatches_text(self): # Remove the family where parent is married to a child self.famMap["F10"] = { "HUSB": ["I21"], "WIFE": ["I20"], "CHIL": ["I22", "I21"], "MARR": [8, 3, 2019], "FAM": "F10", "NOTE": "MARSHALL/DUNPHY FAMILY" } self.indMap["I5"] = { "NAME": "Cameron/Pritchett/", "SEX": "M", "BIRT": [29, 2, 1972], "FAMS": ["F4"], "FAMC": ["F5"], "AGE": 48, "INDI": "I5" } self.indMap["I14"] = { "NAME": "Lily/Pritchett/", "SEX": "F", "BIRT": [19, 2, 2008], "FAMC": ["F4"], "AGE": 12, "INDI": "I14" } self.indMap["I15"] = { "NAME": "Rexford/Pritchett/", "SEX": "M", "BIRT": [1, 4, 2020], "FAMC": ["F4"], "AGE": 0, "INDI": "I15" } self.indMap["I16"] = { "NAME": "Merle/Pritchett/", "SEX": "M", "BIRT": [1, 1, 1943], "FAMS": ["F5"], "AGE": 77, "INDI": "I16" } self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us16_male_last_names() ret = self.logger.get_logs() expected_ret = [] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US39_noMatches(self): # should no matches self.logger.clear_logs() for id, fam in self.famMap.items(): # overwrite all Marriages as one day ago dt = datetime.date.today() - datetime.timedelta(days=1) fam["MARR"] = [dt.day, dt.month, dt.year] spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us39_upcoming_anniversaries() ret = self.logger.get_logs() self.assertEqual(len(ret), 0, "Did not get the expected results")
def test_US17_1family_text(self): # should find 1 match and the following expected result self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us17_no_marr2child(self.parentId2Children) ret = self.logger.get_logs() str1 = "F11: My spouse (I26) is one of my children: Parent (I27), Children (['I26'])" expected_ret = [('Error', 'Family', 17, str1)] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US18_1family_text(self): # should find 1 match and the following expected result self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us18_no_siblingmarriages(self.parentId2Children) ret = self.logger.get_logs() str1 = "F4 has siblings as parents: ['I4', 'I5']" expected_ret = [('Error', 'Family', 18, str1)] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_ThreeOrMoreText(self): # should get the following families with multiple births of 3 or more self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._mult_births(14, 3) ret = self.logger.get_logs() expected_ret = [( 'Warning', 'Family', 14, 'F4 has 3 children with the same birthday (4/1/2020): I28, I29, I30' )] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US32_DefaultCount(self): # should return F4 & F10 family with twins self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck._mult_births(32, 2) ret = self.logger.get_logs() self.assertEqual(len(ret), 2, "Did not get the expected results") expected_ret = [ ('Warning', 'Family', 32, 'F4 has 3 children with the same birthday (4/1/2020): I28, I29, I30' ), ('Warning', 'Family', 32, 'F10 has 2 children with the same birthday (5/8/2019): I22, I23') ] self.assertListEqual(expected_ret, ret, "Expected Return does not match") self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us32_mult_births() ret = self.logger.get_logs() self.assertEqual(len(ret), 2, "Did not get the expected results") expected_ret = [ ('Warning', 'Family', 32, 'F4 has 3 children with the same birthday (4/1/2020): I28, I29, I30' ), ('Warning', 'Family', 32, 'F10 has 2 children with the same birthday (5/8/2019): I22, I23') ] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US39_31daysLaterLen(self): # should no matches self.logger.clear_logs() for id, fam in self.famMap.items(): if id == "F10": dt = datetime.date.today() + datetime.timedelta(days=31) else: dt = datetime.date.today() - datetime.timedelta(days=1) fam["MARR"] = [dt.day, dt.month, dt.year] spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us39_upcoming_anniversaries() ret = self.logger.get_logs() self.assertEqual(len(ret), 0, "Did not get the expected results")
def test_US16_2family_text(self): # should find 1 match and the following expected result self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us16_male_last_names() ret = self.logger.get_logs() expected_ret = [ ('Warning', 'Family', 16, "F4 has multiple last names: ['Pritchett', 'Tucker', 'Tucker-Pritchett']" ), ('Warning', 'Family', 16, "F10 has multiple last names: ['Hastings', 'Marshall']") ] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US18_nomatches(self): self.famMap["F4"] = { "HUSB": ["I4", "I5"], "CHIL": ["I14", "I15"], "MARR": [1, 1, 2014], "NOTE": "PRITCHETT/TUCKER FAMILY", "FAM": "F4", "WIFE": [] } # Remove the family where parent is married to a child self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us18_no_siblingmarriages(self.parentId2Children) ret = self.logger.get_logs() self.assertEqual(len(ret), 0, "Did not get the expected results")
def test_US16_1family(self): # should to get 1 match self.famMap["F10"] = { "HUSB": ["I21"], "WIFE": ["I20"], "CHIL": ["I22", "I21"], "MARR": [8, 3, 2019], "FAM": "F10", "NOTE": "MARSHALL/DUNPHY FAMILY" } self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us16_male_last_names() ret = self.logger.get_logs() self.assertEqual(len(ret), 1, "Did not get the expected results")
def test_US17_nomatches(self): # Remove the family where parent is married to a child self.famMap["F11"] = { "HUSB": ["I26"], "WIFE": ["I27"], "CHIL": ["I3"], "MARR": [16, 1, 2018], "NOTE": "MarryToChildFAMILY", "FAM": "F11" } self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us17_no_marr2child(self.parentId2Children) ret = self.logger.get_logs() self.assertEqual(len(ret), 0, "Did not get the expected results")
def test_US39_31daysLater(self): # should no matches self.logger.clear_logs() for id, fam in self.famMap.items(): if id == "F10": dt = datetime.date.today() + datetime.timedelta(days=31) else: dt = datetime.date.today() - datetime.timedelta(days=1) fam["MARR"] = [dt.day, dt.month, dt.year] spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us39_upcoming_anniversaries() # should find 1 match and the following expected result ret = self.logger.get_logs() expected_ret = [] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US18_nomatches_text(self): # Remove the family where parent is married to a child self.famMap["F4"] = { "HUSB": ["I4", "I5"], "CHIL": ["I14", "I15"], "MARR": [1, 1, 2014], "NOTE": "PRITCHETT/TUCKER FAMILY", "FAM": "F4", "WIFE": [] } self.logger.clear_logs() self.parentId2Children = getParent2ChildrenMap(self.famMap) for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us18_no_siblingmarriages(self.parentId2Children) ret = self.logger.get_logs() expected_ret = [] self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US15_FifteenorMore(self): # add in siblings to family 4 to make 15 - should get one family to match for i in range(28, 39): self.indMap["I"+str(i)] = { "NAME": "I" + str(i) + "/Hastings/", "SEX": "F", "BIRT": [28, 11, 1970], "FAMC": ["F4"], "NOTE": "Adding Child to Family F4", "INDI": "I" + str(i) } self.famMap["F4"]["CHIL"].append("I" + str(i)) self.logger.clear_logs() for id, fam in self.famMap.items(): spousecheck = spouseCrossChecker(self.logger, fam, self.indMap) spousecheck.us15_sibling_count() ret = self.logger.get_logs() self.assertEqual(len(ret), 1, "Did not get the expected results")