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 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_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_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_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 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 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_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_SixSiblingsBornSameTime(self): child = self.child child1 = self.child1 child2 = self.child2 child3 = self.child3 child4 = self.child4 child5 = self.child5 child6 = Individual("I7") fam = self.fam fam.childrenObjects.append(child6) #added child child.birthDateObject = datetime(2013, 9, 14) child1.birthDateObject = datetime(2013, 9, 14) child2.birthDateObject = datetime(2013, 9, 14) child3.birthDateObject = datetime(2013, 9, 14) child4.birthDateObject = datetime(2013, 9, 14) child5.birthDateObject = datetime(2013, 9, 14) child6.birthDateObject = datetime(2010, 10, 23) US16_Multiple_births(fam) self.assertEqual(len(fam.anomalies), 1) self.assertEqual(fam.anomalies, ["Too many births at one time"])
def test_ValidBirthDate(self): indiv = Individual("I1") indiv.birthDateObject = datetime(1996, 9, 24) US01_check_date_before_today_error(indiv, "Birth") self.assertEqual(len(indiv.errors), 0) self.assertEqual(indiv.errors, [])
def test_InvalidBirthDate(self): indiv = Individual("I1") indiv.birthDateObject = datetime(2030, 9, 24) US01_check_date_before_today_error(indiv, "Birth") self.assertEqual(len(indiv.errors), 1) self.assertEqual(indiv.errors[0], "Birth date is after current date")