def test_get_siblings(self): member = Member(5, "Dummy", "Male") mother = Member(9, "Mother", "Female") son = Member(7, "Son", "Male") daughter = Member(7, "Daughter", "Female") self.assertEqual(member.get_siblings(), []) member.mother = mother self.assertEqual(member.get_siblings(), []) mother.children.extend([member, son, daughter]) member.mother = mother siblings = member.get_siblings() self.assertEqual(len(siblings), 2)
def test_get_maternal_grandmother(self): member = Member(9, "Newmember", "Male") mother = Member(10, "Newmember_mother", "Female") grandmother = Member(11, "Newmember_grandmother", "Female") # error cases self.assertEqual(member.get_paternal_grandmother(), None) member.mother = mother self.assertEqual(member.get_paternal_grandmother(), None) member.mother.mother = grandmother self.assertEqual(member.get_maternal_grandmother(), grandmother)