def test_US30_RemoveJayGloriaMarriage(self): # Make Mitchell Dead & Jay and Gloria were never married self.famMap["F1"]["MARR"] = [] self.indMap["I4"]["DEAT"] = [28, 12, 2021] expected_ret = ['I16', 'I17', 'I7', 'I6', 'I21', 'I20', 'I26', 'I27'] ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertEqual(len(ret), 8, "Did not get the expected results") self.assertListEqual(expected_ret, ret, "Expected Return does not match") def test_US31_NoLivingMarried(self): # Test No married individuals by makin them all dead LivingMarried = [ 'I1', 'I2', 'I4', 'I5', 'I16', 'I17', 'I7', 'I6', 'I21', 'I20', 'I26', 'I27' ] # Make all the living singles dead for id, ind in self.indMap.items(): if id in LivingMarried: self.indMap[id]["DEAT"] = [28, 12, 2021] expected_ret = [] ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertEqual(len(ret), 0, "Did not get the expected results") self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US30_Existing_text(self): # should match the following expected result for married individuals expected_ret = [ 'I1', 'I2', 'I4', 'I5', 'I16', 'I17', 'I7', 'I6', 'I21', 'I20', 'I26', 'I27' ] ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US30_AddAnotherSameSexMarriageDeath(self): # Make Mitchell Dead - so then Cam should not be included either self.indMap["I4"]["DEAT"] = [28, 12, 2021] expected_ret = [ 'I1', 'I2', 'I16', 'I17', 'I7', 'I6', 'I21', 'I20', 'I26', 'I27' ] ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertEqual(len(ret), 10, "Did not get the expected results") self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US30_AddAnotherDeath(self): # Make Jay Dead - so Gloria is then a widower and Jay is Dead self.indMap["I1"]["DEAT"] = [28, 12, 2021] expected_ret = [ 'I4', 'I5', 'I16', 'I17', 'I7', 'I6', 'I21', 'I20', 'I26', 'I27' ] ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertEqual(len(ret), 10, "Did not get the expected results") self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US30_AddDivorce(self): # Make Family 10 - Haley/Dillon divorced so 2 less married individuals self.famMap["F10"]["DIV"] = [8, 4, 2019] expected_ret = [ 'I1', 'I2', 'I4', 'I5', 'I16', 'I17', 'I7', 'I6', 'I26', 'I27' ] ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertEqual(len(ret), 10, "Did not get the expected results") self.assertListEqual(expected_ret, ret, "Expected Return does not match")
def test_US30_noinputs(self): # bad inputs with self.assertRaises(Exception): us30_get_married_individuals(None, None) with self.assertRaises(Exception): us30_get_married_individuals(self.famMap) with self.assertRaises(Exception): us30_get_married_individuals(self.indMap)
def test_US30_Existing(self): # should to get 12 married individuals on the original test data ret = us30_get_married_individuals(self.indMap, self.famMap) self.assertEqual(len(ret), 12, "Did not get the expected results")