Beispiel #1
0
    def test_link_members_inferred(self):
        """ test that link_members works with parents from child lines
        """

        child1 = Person('A', 'B', 'C', 'D', '1', '1')
        child2 = Person('A', 'E', 'C', 'D', '1', '1')
        fam = Family('A')
        fam.add_person(child1)
        fam.add_person(child2)

        fam = link_members(fam)

        # getting a list or iterator of family members doesn't include parents
        # only described in child lines
        self.assertEqual(set(fam), set([child1, child2]))

        # still identify parents, even though we don't iterate through them
        self.assertEqual(fam.get_mother(child1),
                         Person('A', 'D', 'NA', 'NA', 'female', 'NA'))
        self.assertEqual(fam.get_father(child1),
                         Person('A', 'C', 'NA', 'NA', 'male', 'NA'))
        self.assertEqual(fam.get_mother(child2),
                         Person('A', 'D', 'NA', 'NA', 'female', 'NA'))
        self.assertEqual(fam.get_father(child2),
                         Person('A', 'C', 'NA', 'NA', 'male', 'NA'))
Beispiel #2
0
    def test_get_mother(self):
        """ test getting a mother
        """

        fam = Family('A')
        child = Person('A', 'B', '0', 'C', '1', '1')
        fam.add_person(child)

        # check when no parent available
        self.assertIsNone(fam.get_mother(child))

        mother = Person('A', 'C', '0', '0', '2', '1')
        fam.add_person(mother)
        fam.set_mom(mother, child)
        self.assertEqual(fam.get_mother(child), mother)

        # despite a mother being present, there is still not father
        self.assertIsNone(fam.get_father(child))
Beispiel #3
0
    def test_set_mother_placeholder(self):
        """ check the mother when set with a placeholder mother
        """

        fam = Family('A')
        child = Person('A', 'B', '0', 'C', '1', '1')
        mother = Person('A', 'C', '0', '0', '2', '1')
        placeholder = Person('A', 'C', 'NA', 'NA', 'NA', 'NA')
        fam.add_person(child)
        fam.add_person(mother)

        fam.set_mom(placeholder, child)

        # and check we can still pick up the parent.
        self.assertIsNotNone(fam.get_mother(child))
Beispiel #4
0
    def test_set_mom(self):
        """
        """

        fam = Family('A')
        child = Person('A', 'B', '0', 'C', '1', '1')
        mom = Person('A', 'C', '0', '0', '2', '1')
        fam.add_person(child)
        fam.add_person(mom)
        fam.set_mom(mom, child)
        self.assertEqual(fam.get_mother(child), mom)

        # make sure we can't add a second, different, mother
        mom2 = Person('A', 'D', '0', '0', '2', '1')
        fam.add_person(mom)
        with self.assertRaises(ValueError):
            fam.set_mom(mom2, child)

        # but we can set the original mother again
        fam.set_mom(mom, child)