def testOlderThan150(self): testIndiv1 = Individual("I1") testIndiv1.age = "160" US07_check_age_less_than_150_error(testIndiv1) self.assertEqual(len(testIndiv1.errors), 1) self.assertEqual(testIndiv1.errors[0], "Individual age greater than 150")
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_more_than_15_siblings(self): testFam = self.testFam testFam.childrenObjects.append(Individual("C15")) testFam.childrenObjects.append(Individual("C16")) US17_fewer_than_15_siblings_anomaly(testFam) self.assertEqual(len(testFam.anomalies), 1) self.assertEqual(testFam.anomalies[0], "There should be fewer than 15 siblings in a family")
def test_BirthBeforeDeath(self): indiv = Individual("I1") indiv.alive = False indiv.birthDateObject = datetime(1999, 12, 31) indiv.deathDateObject = datetime(2000, 1, 1) US03_check_birth_before_death_error(indiv) self.assertEqual(len(indiv.errors), 0) self.assertEqual(indiv.errors, [])
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 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_no_son(self): testFam1 = self.testFam1 daughter = Individual("I2") daughter.gender = 'F' daughter.name = "Jane /Smith/" testFam1.childrenObjects.append(daughter) US18_male_last_names_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 0) self.assertEqual(testFam1.anomalies, [])
def test_son_same_name(self): testFam1 = self.testFam1 son = Individual("I2") son.gender = 'M' son.name = "Jake /Doe/" testFam1.childrenObjects.append(son) US18_male_last_names_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 0) self.assertEqual(testFam1.anomalies, [])
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 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 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 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_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 testBornBeforeAndAfter(self): testFam = self.testFam testChild1 = self.testChild1 testChild2 = Individual("I2") testFam.childrenObjects.append(testChild2) testChild1.birthDateObject = datetime(2018, 5, 3) testChild2.birthDateObject = datetime(2020, 5, 3) US09_check_child_birth_before_marriage_anomaly(testFam) self.assertEqual(len(testFam.anomalies), 1) self.assertEqual(testFam.anomalies[0], "I1 born before parents married")
def test_son_different_name(self): testFam1 = self.testFam1 son = Individual("I2") son.gender = 'M' son.name = "John /Smith/" testFam1.childrenObjects.append(son) US18_male_last_names_anomaly(testFam1) self.assertEqual(len(testFam1.anomalies), 1) self.assertEqual( testFam1.anomalies[0], "Males of the same family should have the same last name")
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 testBornBeforeAndAfter(self): testFam = self.testFam testFam.divorced = True testChild1 = self.testChild1 testChild2 = Individual("I2") testFam.childrenObjects.append(testChild2) testChild1.birthDateObject = datetime(2018, 5, 3) testChild2.birthDateObject = datetime(2020, 5, 3) US12_check_child_birth_after_divorce_anomaly(testFam) self.assertEqual(len(testFam.anomalies), 1) self.assertEqual(testFam.anomalies[0], "I2 born over 9 months after parents divorced")
def test_samename_different_birthday(self): husband = self.husband husband1 = Individual("I3") husband.name = "Mark Ass Colins" husband1.name = "Mark Ass Colins" husband.birthDateString = "1991,10,23" husband1.birthDateString = "1990,10,24" individuals = [husband, husband1] US25_unique_birthday_and_name(individuals) self.assertEqual(len(husband1.errors), 0) self.assertEqual(husband1.errors, [])
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 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_same_name_and_birthday(self): husband = self.husband husband1 = Individual("I3") husband.name = "Mark Ass Colins" husband1.name = "Mark Ass Colins" husband.birthDateString = "1990,10,23" husband1.birthDateString = "1990,10,23" individuals = [husband, husband1] errorMsg = "There are 2 people with the same name and birthday" US25_unique_birthday_and_name(individuals) self.assertEqual(len(husband.errors), 1) self.assertEqual(husband.errors, [errorMsg])
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, [])
def setUp(self): self.child1 = Individual("I1") self.child2 = Individual("I2") self.child3 = Individual("I3") self.child4 = Individual("I4") self.child5 = Individual("I5") self.child1.name = "Child 1" self.child2.name = "Child 2" self.child3.name = "Child 3" self.child4.name = "Child 4" self.child5.name = "Child 5" self.testFam = Family("F1") self.testFam.childrenObjects = [self.child1, self.child2, self.child3, self.child4, self.child5] self.families = [self.testFam]
def test_DeadHusband_ValidDate(self): husband = Individual("I1") wife = Individual("I2") testFam = Family("F1") testFam.divorced = True testFam.husbandId = husband.Id testFam.husbandObject = husband testFam.wifeId = wife.Id testFam.wifeObject = wife husband.alive = False husband.deathDateObject = datetime(2000, 1, 1) testFam.divorceDateObject = datetime(1999, 12, 31) US06_check_divorce_before_spouse_death_error(testFam) self.assertEqual(len(testFam.errors), 0) self.assertEqual(testFam.errors, [])
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_1_birthDate_before_mother_death_1_after(self): wife = Individual("I2") wife.alive = False wife.deathDateObject = datetime(2019, 3, 4) fam = Family("F1") fam.wifeObject = wife child1 = Individual("I3") child1.birthDateObject = datetime(2001, 1, 1) fam.childrenObjects.append(child1) child2 = Individual("I4") child2.birthDateObject = datetime(2020, 1, 1) fam.childrenObjects.append(child2) 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_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_DeadWife_InvalidDate(self): husband = Individual("I7") wife = Individual("I8") testFam = Family("F4") testFam.divorced = True testFam.husbandId = husband.Id testFam.husbandObject = husband testFam.wifeId = wife.Id testFam.wifeObject = wife wife.alive = False wife.deathDateObject = datetime(1999, 12, 31) testFam.divorceDateObject = datetime(2000, 1, 1) US06_check_divorce_before_spouse_death_error(testFam) self.assertEqual(len(testFam.errors), 1) self.assertEqual(testFam.errors[0], "Divorce date is after wife death date")
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")