def test_get_siblings(self): member = Person(5, "Dummy", "Male") mother = Person(9, "Mother", "Female") son = Person(7, "Son", "Male") daughter = Person(7, "Daughter", "Female") self.assertEqual(Relations().get_siblings(member), []) member.mother = mother self.assertEqual(Relations().get_siblings(member), []) mother.children.extend([member, son, daughter]) member.mother = mother siblings = Relations().get_siblings(member) self.assertEqual(len(siblings), 2)
def test_get_siblings(self): person = Person(5, "Dummy", "Male") mother = Person(9, "Mother", "Female") son = Person(7, "Son", "Male") daughter = Person(7, "Daughter", "Female") self.assertEqual(person.get_siblings(), []) person.mother = mother self.assertEqual(person.get_siblings(), []) mother.children.extend([person, son, daughter]) person.mother = mother siblings = person.get_siblings() self.assertEqual(len(siblings), 2)
def test_get_maternal_grandmother(self): member = Person(7, "alpha", "Male") mother = Person(8, "beta", "Female") grandmother = Person(9, "charlie", "Female") # error cases self.assertEqual(Relations().get_paternal_grandmother(member), None) member.mother = mother self.assertEqual(Relations().get_paternal_grandmother(member), None) member.mother.mother = grandmother self.assertEqual(Relations().get_maternal_grandmother(member), grandmother)
def test_get_maternal_grandmother(self): child = Person(7, "alpha", "Male") mother = Person(8, "beta", "Female") grandmother = Person(9, "charlie", "Female") # error cases self.assertEqual(child.get_paternal_grandmother(), None) child.mother = mother self.assertEqual(child.get_paternal_grandmother(), None) child.mother.mother = grandmother self.assertEqual(child.get_maternal_grandmother(), grandmother)