Beispiel #1
0
    def test_add_child(self):
        result = self.ftree.add_child("Father", "Male")
        self.assertEqual(result, constants.CHILD_ADDITION_SUCCEEDED)
        self.assertEqual(
            self.ftree.family_tree.get("Father", None) is not None,
            True
        )

        self.assertEqual(
            self.ftree.add_child("Zim", "Male", "Mother"),
            constants.PERSON_NOT_FOUND
        )
        self.assertEqual(
            self.ftree.add_child("Zim", "Male", "Father"),
            constants.CHILD_ADDITION_FAILED
        )

        mother = Member(2, "Mother", "Female")
        mother.spouse = self.ftree.family_tree["Father"]
        self.ftree.family_tree["Father"].set_spouse(mother)
        self.ftree.family_tree["Mother"] = mother

        self.assertEqual(
            self.ftree.add_child("Zim", "Male", "Mother"),
            constants.CHILD_ADDITION_SUCCEEDED
        )
        self.assertEqual(
            self.ftree.add_child("Zim", "Male", "Mother"),
            constants.CHILD_ADDITION_FAILED
        )
        self.assertEqual(
            self.ftree.family_tree.get("Zim", None) is not None,
            True
        )
    def test_get_spouse_mother(self):
        member = Member(9, "Newmember", "Male")
        spouse = Member(10, "Newmember_spouse", "Female")
        spouse_mother = Member(11, "Newmember_spousemother", "Female")

        # error cases
        self.assertEqual(member.get_spouse_mother(), None)

        member.spouse = spouse
        self.assertEqual(member.get_spouse_mother(), None)

        member.spouse.mother = spouse_mother
        self.assertEqual(member.get_spouse_mother(), spouse_mother)