def test_US02_03(self): """ test US02 and US03""" test_person1 = Person() test_person1.id = "I01" test_person1.name = "Marry Sue" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1993" test_person1.age = 27 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "NA" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = [] person_list = [test_person1, test_person2] family_list = [test_family] self.assertEqual(us02(person_list, family_list), 0) self.assertEqual(us03(person_list), 0) person_list[0].birthDate = "29 SEP 2021" self.assertEqual(us02(person_list, family_list), 1) self.assertEqual(us03(person_list), 1) person_list[1].birthDate = "29 SEP 2021" self.assertEqual(us02(person_list, family_list), 2) self.assertEqual(us03(person_list), 2)
def test_US33_41(self): """ test US33 and US41""" test_person1 = Person() test_person1.id = "I01" test_person1.name = "Marry Sue" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1993" test_person1.age = 27 test_person1.alive = False test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "NA" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = ["c1", "c2", "c3"] c1 = Person() c1.id = "c1" c1.name = "c1 Sue" c1.age = 18 c1.gender = "F" c1.birthDate = "29 SEP 2002" c2 = Person() c2.id = "c2" c2.name = "c2 Sue" c2.age = 19 c2.gender = "F" c2.birthDate = "2 SEP 2001" c3 = Person() c3.id = "c3" c3.name = "c3 Sue" c3.age = 17 c3.gender = "F" c3.birthDate = "1 SEP 2003" person_list = [test_person1, test_person2, c1, c2, c3] family_list = [test_family] # for us 41 modification made in parser # so us41 doesn't have code for testing self.assertEqual(us33(person_list, family_list), 1)
def test_34_42(self): """ test whether us34 and us42 work well """ husband = Person() husband.id = "I01" husband.name = "Jotaro /Kujo/" husband.gender = "M" husband.birthDate = "29 SEP 1918" husband.age = 101 husband.alive = True husband.death = "N/A" husband.child = ["I03"] husband.spouse = ["I02"] wife = Person() wife.id = "I02" wife.name = "Marry Sue" wife.gender = "F" wife.birthDate = "12 Jan 1988" wife.age = 80 wife.alive = False wife.death = "32 JAN 2020" wife.child = [] wife.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "33 JAN 2020" test_family.husbandID = "I01" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I02" test_family.wifeName = "Marry Sue" test_family.chidren = ["I03"] personList = [husband, wife] familiList = [test_family] self.assertEqual( us34(personList, familiList), "There are some couples who were married when the older spouse was more than twice as old as the younger spouse" ) self.assertEqual( us42(personList, familiList), "Not all dates are legitimate dates for the months specified.")
def test_US15_18(self): """ test US15 and US18""" test_person1 = Person() test_person1.id = "I01" test_person1.name = "Marry Sue" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1993" test_person1.age = 27 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "NA" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = [ "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "c12", "c13", "c14", "c15", "c16" ] test_family2 = Family() test_family.id = "F02" test_family.husbandID = "c1" test_family.wifeID = "c2" person_list = [test_person1, test_person2] family_list = [test_family, test_family2] self.assertEqual(us15(family_list), 1) self.assertEqual(us18(family_list), 1)
def test_us12_16(self): """ test whether us12 and us16 work well """ father = Person() father.id = "I01" father.name = "Jotaro /Kujo/" father.gender = "M" father.birthDate = "29 SEP 1918" father.age = 101 father.alive = True father.death = "N/A" father.child = ["I03"] father.spouse = ["I02"] mother = Person() mother.id = "I02" mother.name = "Marry Sue" mother.gender = "F" mother.birthDate = "12 Jan 1988" mother.age = 80 mother.alive = False mother.death = "23 JAN 2020" mother.child = [] mother.spouse = ["I01"] child = Person() child.id = "I03" child.name = "Jolyne /Cujoh/" child.gender = "M" child.birthDate = "12 Jan 2002" child.age = 18 child.alive = True child.death = "N/A" child.child = [] child.spouse = [] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "25 JAN 2020" test_family.husbandID = "I01" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I02" test_family.wifeName = "Marry Sue" test_family.chidren = ["I03"] person_list = [father, mother, child] family_list = [test_family] self.assertEqual(us12(person_list, family_list), "Not all mothers are less than 60 years older than their children, or all fathers are less than 80 years older than their children") self.assertEqual(us16(person_list, family_list), "Not all male members of a family have the same last name")
def test_US24_25(self): test_person1 = Person() test_person1.id = "d1" test_person1.name = "Jack Sue" test_person1.gender = "M" test_person1.birthDate = "1 JAN 1986" test_person1.age = 34 test_person1.alive = True test_person1.death = "N/A" test_person1.child = [] test_person1.spouse = ["d2"] test_person2 = Person() test_person2.id = "d2" test_person2.name = "Rose Sue" test_person2.gender = "F" test_person2.birthDate = "1 JAN 1987" test_person2.age = 33 test_person2.alive = True test_person2.death = "N/A" test_person2.child = [] test_person2.spouse = ["d1"] test_person3 = Person() test_person3.id = "d3" test_person3.name = "Jack Sue" test_person3.gender = "M" test_person3.birthDate = "1 JAN 1986" test_person3.age = 34 test_person3.alive = True test_person3.death = "N/A" test_person3.child = [] test_person3.spouse = ["d4"] test_person4 = Person() test_person4.id = "d4" test_person4.name = "Rose Sue" test_person4.gender = "F" test_person4.birthDate = "1 JAN 1987" test_person4.age = 33 test_person4.alive = True test_person4.death = "N/A" test_person4.child = [] test_person4.spouse = ["d3"] test_person5 = Person() test_person5.id = "US25C" test_person5.name = "Mary Zhang" test_person5.gender = "M" test_person5.birthDate = "1 JAN 2019" test_person5.age = 34 test_person5.alive = True test_person5.death = "N/A" test_person5.child = [] test_person5.spouse = [] test_person6 = Person() test_person6.id = "US25D" test_person6.name = "Mary Zhang" test_person6.gender = "F" test_person6.birthDate = "1 JAN 2019" test_person6.age = 34 test_person6.alive = True test_person6.death = "N/A" test_person6.child = [] test_person6.spouse = [] test_family = Family() test_family.id = "f4" test_family.married = "DATE 1 JAN 2018" test_family.divorce = "NA" test_family.husbandID = "d1" test_family.husbandName = "Jack Sue" test_family.wifeID = "d2" test_family.wifeName = "Rose Sue" test_family.chidren = [] test_family2 = Family() test_family2.id = "f5" test_family2.married = "DATE 1 JAN 2018" test_family2.divorce = "NA" test_family2.husbandID = "d3" test_family2.husbandName = "Jack Sue" test_family2.wifeID = "d4" test_family2.wifeName = "Rose Sue" test_family2.chidren = ["US25C", "US25D"] person_list = [ test_person1, test_person2, test_person3, test_person4, test_person5, test_person6 ] family_list = [test_family, test_family2] self.assertEqual(us24(family_list), None) self.assertEqual(us25(person_list, family_list), None)
def test_us38_39(self): test_person1 = Person() test_person1.id = "I01" test_person1.name = "child" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1900" test_person1.age = 44 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "1 MAY 1988" test_person2.age = 55 test_person2.alive = True test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_person3 = Person() test_person3.id = "I03" test_person3.name = "Haizi" test_person3.gender = "M" test_person3.birthDate = "12 Jan 1996" test_person3.age = 45 test_person3.alive = True test_person3.death = "23 JAN 2020" test_person3.child = [] test_person3.spouse = [] test_family = Family() test_family.id = "F01" test_family.married = "1 MAY 1993" test_family.divorce = "NA" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = [] person_list = [test_person1, test_person2, test_person3] family_list = [test_family] self.assertEqual(us38(person_list), ["I02"]) self.assertEqual(us39(person_list, family_list), ["F01"])
def test_US27_28(self): """ test US27 and US28""" test_person1 = Person() test_person1.id = "I01" test_person1.name = "Marry Sue" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1993" test_person1.age = 27 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "NA" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = ["c1", "c2", "c3"] c1 = Person() c1.id = "c1" c1.name = "c1 Sue" c1.gender = "F" c1.birthDate = "29 SEP 2000" c2 = Person() c2.id = "c2" c2.name = "c2 Sue" c2.gender = "F" c2.birthDate = "2 SEP 2000" c3 = Person() c3.id = "c3" c3.name = "c3 Sue" c3.gender = "F" c3.birthDate = "1 SEP 2000" person_list = [test_person1, test_person2, c1, c2, c3] family_list = [test_family] family_list2 = [test_family] family_list2[0].children = ['c3', 'c2', 'c1'] #self.assertEqual(us27(family_list), 1) # age is already included in the original individuals pretty table # us27 doesn't have code for testing #print(us28(person_list)) self.assertEqual(us28(person_list, family_list), family_list2)
def test_21_29(self): """ test whether us21 and us29 work well """ husband = Person() husband.id = "I01" husband.name = "Jotaro /Kujo/" husband.gender = "F" husband.birthDate = "29 SEP 1918" husband.age = 101 husband.alive = True husband.death = "N/A" husband.child = ["I03"] husband.spouse = ["I02"] wife = Person() wife.id = "I02" wife.name = "Marry Sue" wife.gender = "M" wife.birthDate = "12 Jan 1988" wife.age = 80 wife.alive = False wife.death = "23 JAN 2020" wife.child = [] wife.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "25 JAN 2020" test_family.husbandID = "I01" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I02" test_family.wifeName = "Marry Sue" test_family.chidren = ["I03"] personList = [husband, wife] familiList = [test_family] self.assertEqual( us21(personList, familiList), "Husband in family is not male or wife in family is not female") self.assertEqual(us29(personList), ['I02'])
def test_us30_31(self): test_person1 = Person() test_person1.id = "I01" test_person1.name = "child" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1900" test_person1.age = 44 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 55 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_person3 = Person() test_person3.id = "I03" test_person3.name = "Haizi" test_person3.gender = "M" test_person3.birthDate = "12 Jan 1996" test_person3.age = 45 test_person3.alive = True test_person3.death = "23 JAN 2020" test_person3.child = [] test_person3.spouse = [] person_list = [test_person1, test_person2, test_person3] self.assertEqual(us30(person_list), ["I01"]) self.assertEqual(us31(person_list), ["I03"])
def test_us07(self): """test for us07""" test_person1 = Person() test_person1.id = "I01" test_person1.name = "Marry Sue" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1800" test_person1.age = 27 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_person3 = Person() test_person3.id = "I03" test_person3.name = "Haizi" test_person3.gender = "M" test_person3.birthDate = "12 Jan 1996" test_person3.age = 10 test_person3.alive = False test_person3.death = "23 JAN 2020" test_person3.child = [] test_person3.spouse = [] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "NA" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = [] person_list = [test_person1, test_person2] family_list = [test_family] self.assertEqual(us07(person_list, family_list), 'Error') self.assertEqual(us08(person_list, family_list), 'Correct')
def test_us01_06(self): """ test whether us01 and us06 work well """ test_person1 = Person() test_person1.id = "I01" test_person1.name = "Marry Sue" test_person1.gender = "F" test_person1.birthDate = "29 SEP 2022" test_person1.age = 27 test_person1.alive = True test_person1.death = "23 JAN 2020" test_person1.child = [] test_person1.spouse = ["I02"] test_person2 = Person() test_person2.id = "I02" test_person2.name = "Morgan Sue" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1988" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["I01"] test_family = Family() test_family.id = "F01" test_family.married = "29 SEP 1993" test_family.divorce = "25 JAN 2020" test_family.husbandID = "I02" test_family.husbandName = "Morgan Sue" test_family.wifeID = "I01" test_family.wifeName = "Marry Sue" test_family.chidren = [] person_list = [test_person1, test_person2] family_list = [test_family] self.assertEqual(us01(person_list, family_list), "Not all dates happen before current date.") self.assertEqual(us06(person_list, family_list), "Not all divorces happen before one is dead.")
def test_US35_36(self): test_person1 = Person() test_person1.id = "d1" test_person1.name = "Jack Sue" test_person1.gender = "M" test_person1.birthDate = "1 APR 2020" test_person1.age = 0 test_person1.alive = True test_person1.death = "N/A" test_person1.child = [] test_person1.spouse = [] test_person2 = Person() test_person2.id = "d2" test_person2.name = "Rose Sue" test_person2.gender = "F" test_person2.birthDate = "1 JAN 1987" test_person2.age = 33 test_person2.alive = False test_person2.death = "16 APR 2020" test_person2.child = [] test_person2.spouse = [] person_list = [test_person1, test_person2] self.assertEqual(us35(person_list), None) self.assertEqual(us36(person_list), None)
def test_US0405(self): test_person1 = Person() test_person1.id = "P0002" test_person1.name = "CCCC" test_person1.gender = "F" test_person1.birthDate = "29 SEP 1973" test_person1.age = 27 test_person1.alive = True test_person1.death = "N/A" test_person1.child = [] test_person1.spouse = ["P0003"] test_person2 = Person() test_person2.id = "P0003" test_person2.name = "DDDD" test_person2.gender = "M" test_person2.birthDate = "12 Jan 1978" test_person2.age = 32 test_person2.alive = False test_person2.death = "23 JAN 2020" test_person2.child = [] test_person2.spouse = ["P0002"] test_family2 = Family() test_family2.id = "F0002" test_family2.married = "23 JAN 2021" test_family2.divorce = "NA" test_family2.husbandID = "P0003" test_family2.husbandName = "DDDD" test_family2.wifeID = "P0002" test_family2.wifeName = "CCCC" test_family2.chidren = [] test_family1 = Family() test_family1.id = "F0001" test_family1.married = "29 SEP 1990" test_family1.divorce = "29 sep 1988" test_family1.husbandID = "P0001" test_family1.husbandName = "AAAA" test_family1.wifeID = "P0002" test_family1.wifeName = "BBB" test_family1.chidren = [] fileName = "Sprint1US0405Output.txt" person_list = [test_person1, test_person2] family_list = [test_family1, test_family2] self.assertEqual(us0405(family_list, person_list), None)