def testAllRightAgeMarried(self): list_of_indis = [ Individual(indi='01', age=20, spouse='F01'), Individual(indi='02', age=25, spouse='F02'), Individual(indi='03', age=29, spouse='F03') ] self.assertListEqual(list_living_single(list_of_indis), [])
def testAllLivingSingle(self): list_of_indis = [ Individual(indi='01', age=20), Individual(indi='02', age=25), Individual(indi='03', age=29) ] self.assertEqual(len(list_living_single(list_of_indis)), 3)
def testAllTooOldUnmarried(self): list_of_indis = [ Individual(indi='01', age=45), Individual(indi='02', age=55), Individual(indi='03', age=65) ] self.assertListEqual(list_living_single(list_of_indis), [])
def testChildrenWithoutIndis(self): list_of_children = ['Oldest', 'Fake', 'Youngest'] list_of_indis = [ Individual(indi='Oldest', age=11), Individual(indi='Youngest', age=2) ] desired_result = ['Oldest', 'Youngest'] self.assertListEqual( order_siblings_by_age(list_of_children, list_of_indis), desired_result)
def testSomeLivingSingle(self): list_of_indis = [ Individual(indi='01', age=20, spouse='F01'), Individual(indi='02', age=25), Individual(indi='03', age=29, birth='1 JAN 1990', death='1 JAN 2019'), Individual(indi='04', age=65) ] self.assertListEqual(list_living_single(list_of_indis), ['02'])
def testManyChildren(self): list_of_children = ['1', '2', '3', '4', '5'] list_of_indis = [ Individual(indi='1', age=1), Individual(indi='2', age=2), Individual(indi='3', age=3), Individual(indi='4', age=4), Individual(indi='5', age=5) ] desired_result = ['5', '4', '3', '2', '1'] self.assertListEqual( order_siblings_by_age(list_of_children, list_of_indis), desired_result)
def testNoLiving(self): list_of_indis = [ Individual(indi='01', age=29, birth='1 JAN 1990', death='1 JAN 2019'), Individual(indi='02', age=49, birth='1 JAN 1970', death='1 JAN 2019'), Individual(indi='03', age=19, birth='1 JAN 2000', death='1 JAN 2019') ] self.assertListEqual(list_living_single(list_of_indis), [])
def testNoChildren(self): list_of_children = [] list_of_indis = [Individual(indi='01', age=49)] self.assertListEqual( order_siblings_by_age(list_of_children, list_of_indis), [])
def testOneChild(self): list_of_children = ['OnlyChild'] list_of_indis = [Individual(indi='OnlyChild', age=11, child='F01')] desired_result = ['OnlyChild'] actual = order_siblings_by_age(list_of_children, list_of_indis) self.assertListEqual(actual, desired_result)