def testErrorDivorce(self): testFam1 = Family("F1") testFam1.divorced = True testFam1.marriageDateObject = datetime(2019, 5, 3) testFam1.divorceDateObject = datetime(2018, 5, 3) US05_check_marriage_before_divorce_error(testFam1) self.assertEqual(len(testFam1.errors), 1) self.assertEqual(testFam1.errors[0], "Divorce date is before marriage date")
def test_unique_for_families(self): testFam1 = self.testFam1 testFam2 = Family("F2") testFam3 = Family("F3") families = [testFam1, testFam2, testFam3] US24_Unique_IDs(families, "families") self.assertEqual(len(testFam1.errors), 0) self.assertEqual(testFam1.errors, [])
def test_husband_spouseFam_valid(self): husband = Individual("I1") testFam = Family("F1") testFam.husbandObject = husband husband.spouseFamilyObjects.append(testFam) US28_corresponding_family_entries_error(testFam) self.assertEqual(len(testFam.errors), 0) self.assertEqual(testFam.errors, [])
def testValidDivorce(self): testFam2 = Family("F2") testFam2.divorced = True testFam2.marriageDateObject = datetime(2018, 5, 3) testFam2.divorceDateObject = datetime(2019, 5, 3) US05_check_marriage_before_divorce_error(testFam2) self.assertEqual(len(testFam2.errors), 0) self.assertEqual(testFam2.errors, [])
def test_indiv_spouseFam_valid(self): indiv = Individual("I1") testFam = Family("F1") indiv.spouseFamilyObjects.append(testFam) testFam.wifeObject = indiv US28_corresponding_individual_entries_error(indiv) self.assertEqual(len(indiv.errors), 0) self.assertEqual(indiv.errors, [])
def test_childFam_two_invalid(self): child1 = Individual("I1") child2 = Individual("I2") testFam = Family("F1") testFam.childrenObjects = [child1, child2] US28_corresponding_family_entries_error(testFam) self.assertEqual(len(testFam.errors), 2) self.assertEqual(testFam.errors[0], "Corresponding child family not listed for I1") self.assertEqual(testFam.errors[1], "Corresponding child family not listed for I2")
def test_mother_alive(self): wife = Individual("I2") fam = Family("F1") fam.wifeObject = wife child1 = Individual("I3") child1.birthDateObject = datetime(2001, 1, 1) fam.childrenObjects.append(child1) US08_check_child_birth_before_mother_death_error(fam) self.assertEqual(len(fam.errors), 0) self.assertEqual(fam.errors, [])
def test_childFam_valid(self): child1 = Individual("I1") child2 = Individual("I2") testFam = Family("F1") child1.childFamilyObject = testFam child2.childFamilyObject = testFam testFam.childrenObjects = [child1, child2] US28_corresponding_family_entries_error(testFam) self.assertEqual(len(testFam.errors), 0) self.assertEqual(testFam.errors, [])
def test_wife_spouseFam_invalid_husband_spouseFam_invalid(self): wife = Individual("I1") husband = Individual("I2") testFam = Family("F1") testFam.wifeObject = wife testFam.husbandObject = husband US28_corresponding_family_entries_error(testFam) self.assertEqual(len(testFam.errors), 2) self.assertEqual(testFam.errors[0], "Corresponding spouse family not listed for husband individual") self.assertEqual(testFam.errors[1], "Corresponding spouse family not listed for wife individual")
def test_different_child_fam(self): husband = self.husband wife = self.wife testFam1 = self.testFam1 testFam2 = Family("F2") testFam3 = Family("F3") husband.childFamilyObject = testFam2 wife.childFamilyObject = testFam3 US20_siblings_should_not_marry_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 0) self.assertEqual(testFam1.anomalies, [])
def setUp(self): self.husband = Individual("I1") self.wife = Individual("I2") self.husband1 = Individual("I3") self.wife1 = Individual("I4") self.testFam1 = Family("F1") self.testFam2 = Family("F2") self.testFam1.husbandObject = self.husband self.testFam1.wifeObject = self.wife self.testFam2.husbandObject = self.husband1 self.testFam2.wifeObject = self.wife1
def test_BirthBeforeMarriage(self): husband = Individual("I1") wife = Individual("I2") fam = Family("F1") husband.birthDateObject = datetime(1977, 2, 1) wife.birthDateObject = datetime(1977, 2, 1) fam.husbandObject = husband fam.wifeObject = wife fam.marriageDateObject = datetime(2020, 12, 31) US02_birth_before_marriage_error(fam) self.assertEqual(len(fam.errors), 0) self.assertEqual(fam.errors, [])
def setUp(self): self.husband = Individual("I1") self.wife = Individual("I2") self.fam1 = Family("F1") self.fam2 = Family("F2") self.fam3 = Family("F3") self.fam1.marriageDateObject = datetime(2016, 5, 3) self.fam2.marriageDateObject = datetime(2018, 5, 3) self.fam3.marriageDateObject = datetime(2017, 5, 3) self.fam1.husbandObject = self.husband self.fam2.husbandObject = self.husband self.fam3.husbandObject = self.husband
def test_bothOlderThan14(self): wife = Individual("I1") husband = Individual("I2") fam = Family("F1") fam.wifeObject = wife fam.husbandObject = husband fam.wifeObject.birthDateObject = datetime(1992, 9, 14) fam.husbandObject.birthDateObject = datetime(1995, 9, 14) fam.marriageDateObject = datetime(2013, 9, 14) US10_check_marriage_after_14_anomaly(fam) self.assertEqual(len(fam.anomalies), 0) self.assertEqual(fam.anomalies, [])
def test_birthDate_after_mother_death(self): wife = Individual("I2") wife.alive = False wife.deathDateObject = datetime(2000, 3, 4) fam = Family("F1") fam.wifeObject = wife child1 = Individual("I3") child1.birthDateObject = datetime(2001, 1, 1) fam.childrenObjects.append(child1) US08_check_child_birth_before_mother_death_error(fam) self.assertEqual(len(fam.errors), 1) self.assertEqual(fam.errors, ["Child born after death of mother"])
def test_BirthAfterMarriage(self): husband = Individual("I1") wife = Individual("I2") fam = Family("F1") husband.birthDateObject = datetime(2020, 2, 1) wife.birthDateObject = datetime(2020, 5, 1) fam.husbandObject = husband fam.wifeObject = wife fam.marriageDateObject = datetime(1999, 12, 31) US02_birth_before_marriage_error(fam) self.assertEqual(len(fam.errors), 1) self.assertEqual(fam.errors[0], "Marriage occured before birth date")
def test_wifeYoungerThan14(self): wife = Individual("I1") husband = Individual("I2") fam = Family("F1") fam.wifeObject = wife fam.husbandObject = husband fam.wifeObject.birthDateObject = datetime(2000, 9, 14) fam.husbandObject.birthDateObject = datetime(1996, 9, 14) fam.marriageDateObject = datetime(2013, 9, 14) US10_check_marriage_after_14_anomaly(fam) self.assertEqual(len(fam.anomalies), 1) self.assertEqual(fam.anomalies, ["Wife married before 14 anomaly"])
def test_husband_is_father_of_wife(self): husband = self.husband wife = self.wife testFam1 = self.testFam1 testFam2 = Family("F2") testFam3 = Family("F3") husband.spouseFamilyObjects.append(testFam2) husband.spouseFamilyObjects.append(testFam3) wife.childFamilyObject = testFam3 US19_no_marriages_to_descendants_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 1) self.assertEqual(testFam1.anomalies[0], "Parents should not marry their children")
def test_people_over_30_one_married(self): indiv1 = self.indiv1 indiv2 = self.indiv2 indiv3 = Individual("I3") indiv1.age = 45 indiv2.age = 34 indiv3.age = 36 individuals = self.individuals individuals.append(indiv3) fam = Family("F1") fam.husbandObject = indiv1 fam.wifeObjecet = indiv3 indiv1.spouseFamilyObjects.append(fam) indiv3.spouseFamilyObjects.append(fam) self.assertEqual(US34_list_singles(individuals), [indiv2])
def test_father80YearsOlderThanKid(self): wife = Individual("I1") husband = Individual("I2") child = Individual("I3") fam = Family("F1") fam.husbandObject = husband fam.wifeObject = wife fam.wifeObject.birthDateObject = datetime(1995, 9, 14) fam.husbandObject.birthDateObject = datetime(1900, 9, 14) fam.childrenObjects.append(child) child.birthDateObject = datetime(2000, 2, 2) US14_Parents_not_too_old(fam) self.assertEqual(len(fam.anomalies), 1) self.assertEqual(fam.anomalies, ["Father is 80 years older than child/ren"])
def test_indiv_childFam_invalid(self): indiv = Individual("I1") testFam = Family("F1") indiv.childFamilyObject = testFam US28_corresponding_individual_entries_error(indiv) self.assertEqual(len(indiv.errors), 1) self.assertEqual(indiv.errors[0], "Individual not found as child in F1")
def test_indiv_spouseFam_invalid(self): indiv = Individual("I1") testFam = Family("F1") indiv.spouseFamilyObjects.append(testFam) US28_corresponding_individual_entries_error(indiv) self.assertEqual(len(indiv.errors), 1) self.assertEqual(indiv.errors[0], "Individual not found as spouse in F1")
def test_indiv_childFam_valid(self): indiv = Individual("I1") testFam = Family("F1") indiv.childFamilyObject = testFam testFam.childrenObjects.append(indiv) US28_corresponding_individual_entries_error(indiv) self.assertEqual(len(indiv.errors), 0) self.assertEqual(indiv.errors, [])
def ParentsNotDivorced(self): testFam = Family("F2") testChild1 = self.testChild1 testChild1.birthDateObject = datetime(2018, 5, 3) US12_check_child_birth_after_divorce_anomaly(testFam) testFam.childrenObjects.append(testChild1) self.assertEqual(len(testFam.anomalies), 0) self.assertEqual(testFam.anomalies, [])
def setUp(self): self.husband = Individual("I1") self.wife = Individual("I2") self.testFam = Family("F1") self.families = [self.testFam] self.testFam.husbandObject = self.husband self.testFam.wifeObject = self.wife self.husband.name = "John" self.wife.name = "Jane"
def setUp(self): self.fam1 = Family("F1") self.wife = Individual("I1") self.wife.name = "Jane Doe" self.husband = Individual("I2") self.husband.name = "John Doe" self.fam1.wife = self.wife self.fam1.husband = self.husband self.families = [self.fam1]
def test_only_wife_child_fam_set(self): husband = self.husband wife = self.wife testFam1 = self.testFam1 testFam2 = Family("F2") wife.childFamilyObject = testFam2 US20_siblings_should_not_marry_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 0) self.assertEqual(testFam1.anomalies, [])
def setUp(self): self.wife = Individual("I1") self.husband = Individual("I2") self.child = Individual("I3") self.child1 = Individual("I4") self.fam = Family("F1") self.fam.husbandObject = self.husband self.fam.wifeObject = self.wife self.fam.childrenObjects.append(self.child) #added child self.fam.childrenObjects.append(self.child1) #added child
def test_same_child_fam(self): husband = self.husband wife = self.wife testFam1 = self.testFam1 testFam2 = Family("F2") husband.childFamilyObject = testFam2 wife.childFamilyObject = testFam2 US20_siblings_should_not_marry_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 1) self.assertEqual(testFam1.anomalies[0], "Siblings should not marry")
def test_BothAlive(self): husband = Individual("I9") wife = Individual("I10") testFam = Family("F5") testFam.divorced = True testFam.husbandId = husband.Id testFam.husbandObject = husband testFam.wifeId = wife.Id testFam.wifeObject = wife testFam.divorceDateObject = datetime(2000, 1, 1) US06_check_divorce_before_spouse_death_error(testFam) self.assertEqual(len(testFam.errors), 0) self.assertEqual(testFam.errors, [])