Beispiel #1
0
    def test_US12_parents_not_too_old(self):
        t1 = Family("t1")
        t2 = Family("t2")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        t1.set_wife(p1)
        t1.set_husband(p2)
        t1.add_child(p3)
        t2.set_wife(p4)
        t2.set_husband(p5)
        t2.add_child(p6)
        p1.set_birthDate(["1", "JAN", "1990"])
        p2.set_birthDate(["1", "JAN", "1990"])
        p4.set_birthDate(["1", "JAN", "1790"])
        p5.set_birthDate(["1", "JAN", "1790"])

        p3.set_birthDate(["1", "JAN", "2010"])
        p6.set_birthDate(["1", "JAN", "2000"])
        # ---------------------------------
        assert t1.parents_not_too_old() == True
        assert t2.parents_not_too_old() == False
 def test3(self):
     male1 = Individual("P01")
     female1 = Individual("P02")
     child1 = Individual("P03")
     family1 = Family("F01")
     family1.add_child(child1)
     male1.set_deathDate(["5", "MAR", "2000"])
     female1.set_deathDate(["9", "APR", "2002"])
     child1.set_birthDate(["6", "MAR", "2000"])
     family1.set_husband(male1)
     family1.set_wife(female1)
     self.assertTrue(family1.birth_before_death_of_parents())
Beispiel #3
0
 def test_US17_No_marriages_to_descendants(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     p1 = Individual("p1")
     p2 = Individual("p2")
     p3 = Individual("p3")
     p4 = Individual("p4")
     p5 = Individual("p5")
     p6 = Individual("p6")
     p7 = Individual("p7")
     p8 = Individual("p8")
     p9 = Individual("p9")
     t1.set_husband(p1)
     t1.set_wife(p2)
     t1.add_child(p3)
     t2.set_wife(p3)
     t2.set_husband(p4)
     t2.add_child(p5)
     t3.set_husband(p6)
     t3.set_wife(p7)
     t3.add_child(p8)
     t4.set_husband(p6)
     t4.set_wife(p8)
     t4.add_child(p9)
Beispiel #4
0
    def test_US19_First_cousins_should_not_marry(self):
        t1 = Family("t1")
        t2 = Family("t2")
        t3 = Family("t3")
        t4 = Family("t4")
        t5 = Family("t5")
        t6 = Family("t6")
        t7 = Family("t7")
        t8 = Family("t8")
        t9 = Family("t9")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        p7 = Individual("p7")
        p8 = Individual("p8")
        # --------------------------------------------------
        '''
        t1.add_child(p1)
        t1.add_child(p2)
        t2.set_wife(p1)
        t2.add_child(p3)
        t3.set_wife(p2)
        t3.add_child(p4)
        t4.set_husband(p3)
        t5.set_wife(p4)
        
        t6.add_child(p5)
        t6.add_child(p6)
        t7.set_wife(p5)
        t8.set_wife(p6)
        t7.add_child(p7)
        t8.add_child(p8)
        t9.set_wife(p7)
        t9.set_husband(p8)
        '''
        # --------------------------------------------------
        p3.set_parentFamily(t1)
        t1.set_husband(p8)
        t1.set_wife(p7)
        p8.set_parentFamily(t2)
        p7.set_parentFamily(t3)
        t2.add_child(p8)
        t3.add_child(p7)

        assert p3.first_cousins_should_not_marry() == True
Beispiel #5
0
 def test_US08_birth_before_marriage_of_parents(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     child1 = Individual("P03")
     t1.add_child(child1)
     t1.set_marriedDate(['8', 'SEP', '2000'])
     child1.set_birthDate(["6", "JAN", "1998"])
     t1.set_husband(male1)
     t1.set_wife(female1)
     # ---------------------------------
     t2 = Family("F02")
     male2 = Individual("P04")
     female2 = Individual("P05")
     child2 = Individual("P06")
     t2.add_child(child2)
     t2.set_marriedDate(['8', 'SEP', '2000'])
     child2.set_birthDate(["6", "JAN", "2001"])
     t2.set_husband(male2)
     t2.set_wife(female2)
     # ---------------------------------
     t3 = Family("F03")
     male3 = Individual("P07")
     female3 = Individual("P08")
     child3 = Individual("P09")
     t3.add_child(child3)
     t3.set_marriedDate(['6', 'MAR', '2000'])
     child3.set_birthDate(["6", "MAR", "2000"])
     t3.set_husband(male3)
     t3.set_wife(female3)
     # ---------------------------------
     assert t1.birth_before_marriage_of_parents() == False
     assert t2.birth_before_marriage_of_parents() == True
     assert t3.birth_before_marriage_of_parents() == False
Beispiel #6
0
 def test_US09_birth_before_death_of_parent(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     child1 = Individual("P03")
     t1.add_child(child1)
     male1.set_deathDate(["5", "MAR", "2000"])
     female1.set_deathDate(["9", "APR", "2002"])
     child1.set_birthDate(["6", "JAN", "1998"])
     t1.set_husband(male1)
     t1.set_wife(female1)
     # ---------------------------------
     t2 = Family("F02")
     male2 = Individual("P04")
     female2 = Individual("P05")
     child2 = Individual("P06")
     t2.add_child(child2)
     male2.set_deathDate(["5", "MAR", "2000"])
     female2.set_deathDate(["9", "APR", "2002"])
     child2.set_birthDate(["6", "JAN", "2001"])
     t2.set_husband(male2)
     t2.set_wife(female2)
     # ---------------------------------
     t3 = Family("F03")
     male3 = Individual("P07")
     female3 = Individual("P08")
     child3 = Individual("P09")
     t3.add_child(child3)
     male3.set_deathDate(["5", "MAR", "2000"])
     female3.set_deathDate(["9", "APR", "2002"])
     child3.set_birthDate(["6", "MAR", "2000"])
     t3.set_husband(male3)
     t3.set_wife(female3)
     # ---------------------------------
     assert t1.birth_before_death_of_parents() == True
     assert t2.birth_before_death_of_parents() == False
     assert t3.birth_before_death_of_parents() == True
Beispiel #7
0
 def test_US28_Order_siblings_by_age(self):
     t1 = Family("t1")
     t2 = Family("t2")
     p1 = Individual("p1")
     p1.set_birthDate((1990, 4, 1))
     p2 = Individual("p2")
     p2.set_birthDate((1990, 1, 1))
     p3 = Individual("p3")
     p3.set_birthDate((1990, 9, 1))
     p4 = Individual("p4")
     p4.set_birthDate((1987, 1, 1))
     p5 = Individual("p5")
     p5.set_birthDate((2019, 1, 1))
     p6 = Individual("p6")
     p6.set_birthDate((2017, 5, 30))
     p7 = Individual("p7")
     p7.set_birthDate((2018, 3, 30))
     p8 = Individual("p8")
     p8.set_birthDate((2019, 8, 30))
     # --------------------------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t1.add_child(p3)
     t1.add_child(p4)
     t1.add_child(p5)
     t1.add_child(p6)
     t2.add_child(p1)
     t2.add_child(p2)
     t2.add_child(p3)
     t2.add_child(p4)
     t2.add_child(p7)
     t2.add_child(p8)
     # --------------------------------------------------
     assert t1.order_siblings_by_age() == [p4, p2, p1, p3, p6, p5]
     assert t2.order_siblings_by_age() == [p4, p2, p1, p3, p7, p8]
Beispiel #8
0
    def test_US16_Male_last_names(self):
        t1 = Family("t1")
        t2 = Family("t2")
        t3 = Family("t3")
        t4 = Family("t4")
        t5 = Family("t5")
        t6 = Family("t6")
        t7 = Family("t7")
        t8 = Family("t8")
        t9 = Family("t9")
        t10 = Family("t10")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        p7 = Individual("p7")
        p8 = Individual("p8")
        p9 = Individual("p9")
        p10 = Individual("p10")
        # --------------------------------------------------
        t1.set_husband(p1)
        t1.add_child(p2)
        t1.add_child(p3)
        t2.set_husband(p2)
        t3.set_husband(p3)
        t2.add_child(p4)
        t3.add_child(p5)
        t4.set_husband(p4)
        t5.set_husband(p5)

        t6.set_husband(p6)
        t6.add_child(p7)
        t6.add_child(p8)
        t7.set_husband(p7)
        t8.set_husband(p8)
        t7.add_child(p9)
        t8.add_child(p10)
        t9.set_husband(p9)
        t10.set_husband(p10)

        p1.set_gender("M")
        p1.set_name("Charles Glass")
        p2.set_gender("M")
        p2.set_name("Charles Glass")
        p3.set_gender("M")
        p3.set_name("Charles Glass")
        p4.set_gender("M")
        p4.set_name("Charles Glass")
        p5.set_gender("M")
        p5.set_name("Charles Glass")

        p6.set_gender("M")
        p6.set_name("Charles Glass")
        p7.set_gender("M")
        p7.set_name("Charles Glass")
        p8.set_gender("M")
        p8.set_name("Charles WDNMD")
        p9.set_gender("M")
        p9.set_name("Charles Glass")
        p10.set_gender("M")
        p10.set_name("Charles Glass")

        # --------------------------------------------------

        assert t3.male_last_names() == True
        assert t8.male_last_names() == False
Beispiel #9
0
    def test_US15_Fewer_than_15_siblings(self):
        t1 = Family("t1")
        t2 = Family("t2")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        p7 = Individual("p7")
        p8 = Individual("p8")
        p9 = Individual("p9")
        p10 = Individual("p10")
        p11 = Individual("p11")
        p12 = Individual("p12")
        p13 = Individual("p13")
        p14 = Individual("p14")
        p15 = Individual("p15")
        p16 = Individual("p16")
        p17 = Individual("p17")
        p18 = Individual("p18")
        p19 = Individual("p19")
        p20 = Individual("p20")
        p21 = Individual("p21")
        p22 = Individual("p22")
        p23 = Individual("p23")
        p24 = Individual("p24")
        p25 = Individual("p25")
        p26 = Individual("p26")
        p27 = Individual("p27")
        p28 = Individual("p28")

        # ---------------------------------
        t1.add_child(p1)
        t1.add_child(p2)
        t1.add_child(p3)
        t1.add_child(p4)
        t1.add_child(p5)
        t1.add_child(p6)
        t1.add_child(p7)
        t1.add_child(p8)
        t1.add_child(p9)
        t1.add_child(p10)
        t1.add_child(p11)
        t1.add_child(p12)
        t2.add_child(p13)
        t2.add_child(p14)
        t2.add_child(p15)
        t2.add_child(p16)
        t2.add_child(p17)
        t2.add_child(p18)
        t2.add_child(p19)
        t2.add_child(p20)
        t2.add_child(p21)
        t2.add_child(p22)
        t2.add_child(p23)
        t2.add_child(p24)
        t2.add_child(p25)
        t2.add_child(p26)
        t2.add_child(p27)
        t2.add_child(p28)
        # ---------------------------------
        assert t1.fewer_than_15_siblings() == True
        assert t2.fewer_than_15_siblings() == False
Beispiel #10
0
 def test_US14_multiple_births_lessOrEqual_than_5(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     p1 = Individual("p1")
     p1.set_birthDate(("1", "JAN", "1990"))
     p2 = Individual("p2")
     p2.set_birthDate(("1", "JAN", "1990"))
     p3 = Individual("p3")
     p3.set_birthDate(("1", "JAN", "1990"))
     p4 = Individual("p4")
     p4.set_birthDate(("3", "JAN", "1990"))
     p5 = Individual("p5")
     p5.set_birthDate(("2", "JAN", "1990"))
     p6 = Individual("p6")
     p6.set_birthDate(("30", "MAY", "1990"))
     p7 = Individual("p7")
     p7.set_birthDate(("2", "JAN", "1990"))
     p8 = Individual("p8")
     p8.set_birthDate(("2", "JAN", "1990"))
     p9 = Individual("p9")
     p9.set_birthDate(("2", "SEP", "1990"))
     p10 = Individual("p10")
     p10.set_birthDate(("2", "SEP", "1990"))
     p11 = Individual("p11")
     p11.set_birthDate(("3", "SEP", "1990"))
     p12 = Individual("p12")
     p12.set_birthDate(("3", "SEP", "1990"))
     p13 = Individual("p13")
     p13.set_birthDate(("3", "SEP", "1990"))
     # -------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t1.add_child(p3)
     t1.add_child(p4)
     t1.add_child(p5)
     t1.add_child(p6)
     t1.add_child(p7)
     t1.add_child(p8)
     t2.add_child(p1)
     t2.add_child(p2)
     t2.add_child(p3)
     t2.add_child(p4)
     t2.add_child(p5)
     t2.add_child(p6)
     t3.add_child(p3)
     t3.add_child(p4)
     t3.add_child(p5)
     t3.add_child(p6)
     t3.add_child(p7)
     t3.add_child(p8)
     t3.add_child(p9)
     t3.add_child(p10)
     t3.add_child(p11)
     t3.add_child(p12)
     t3.add_child(p13)
     # ---------------------------------
     assert t1.multiple_births_lessOrEqual_than_5() == False
     assert t2.multiple_births_lessOrEqual_than_5() == True
     assert t3.multiple_births_lessOrEqual_than_5() == False
Beispiel #11
0
 def test_US13_siblings_spacing(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     t5 = Family("t5")
     t6 = Family("t6")
     p1 = Individual("p1")
     p1.set_birthDate(("1", "JAN", "1990"))
     p2 = Individual("p2")
     p2.set_birthDate(("1", "JAN", "1990"))
     p3 = Individual("p3")
     p3.set_birthDate(("1", "SEP", "1990"))
     p4 = Individual("p4")
     p4.set_birthDate(("2", "JAN", "1990"))
     p5 = Individual("p5")
     p5.set_birthDate(("3", "JAN", "1990"))
     p6 = Individual("p6")
     p6.set_birthDate(("30", "MAY", "1990"))
     # --------------------------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t2.add_child(p1)
     t2.add_child(p3)
     t3.add_child(p1)
     t3.add_child(p4)
     t4.add_child(p1)
     t4.add_child(p5)
     t5.add_child(p1)
     t5.add_child(p6)
     t6.add_child(p1)
     t6.add_child(p3)
     t6.add_child(p6)
     # --------------------------------------------------
     assert t1.siblings_spacing() == True
     assert t2.siblings_spacing() == True
     assert t3.siblings_spacing() == True
     assert t4.siblings_spacing() == False
     assert t5.siblings_spacing() == False
     assert t6.siblings_spacing() == False
Beispiel #12
0
 def parse(self):
     #from Individual import Individual
     #from Family import Family
     offset = 0
     for i in range(len(self._data[1]) - 1):  # enumerate individuals
         start_index = self._data[1][i]
         end_index = self._data[1][i + 1]
         # print(self._data[0][start_index:end_index])
         # TODO: check deplicated ids
         id = self._data[0][start_index][2]
         if id in self._individuals:
             offset += 1
             id = "@I" + str(int(id[2:-1]) + offset) + "@"
         new_indi = Individual(id)
         new_indi.set_lineNum(self._data[3][start_index])
         self._individuals[id] = new_indi
         # print(start_index, end_index)
         for j in range(start_index + 1, end_index):
             level, tag, arguments = self._data[0][j]
             if tag == "NAME":
                 new_indi.set_name("".join(arguments))
             elif tag == "SEX":
                 new_indi.set_gender(arguments[0])
             elif tag == "BIRT":  # set missing dates to Jan/01
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 try:
                     new_indi.set_birthDate(arguments)
                 except ValueError as e:
                     print(e)  # TODO:how to handle error?
             elif tag == "DEAT":
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 new_indi.set_deathDate(arguments)
             elif tag == "FAMS":
                 if arguments[0] not in self._families:
                     new_fam = Family(arguments[0])
                     self._families[arguments[0]] = new_fam
                 new_indi.add_to_family(self._families[arguments[0]])
             elif tag == "FAMC":
                 if arguments[0] not in self._families:
                     new_fam = Family(arguments[0])
                     self._families[arguments[0]] = new_fam
                 new_indi.set_parentFamily(self._families[arguments[0]])
     offset = 0
     for i in range(len(self._data[2]) - 1):
         start_index = self._data[2][i]
         end_index = self._data[2][i + 1]
         # print(self._data[0][start_index:end_index])
         id = self._data[0][start_index][2]
         # if id in self._families:  #TODO: handle duplicate
         #     offset+=1
         #     id = "@F" + str(int(id[2:-1]) + offset) + "@"
         new_fam = Family(id)
         new_fam.set_lineNum(self._data[3][start_index])
         self._families[id] = new_fam
         for j in range(start_index + 1, end_index):
             level, tag, arguments = self._data[0][j]
             # print(level, tag, arguments)
             if tag == "HUSB":
                 new_fam.set_husband(self._individuals[arguments[0]])
             elif tag == "WIFE":
                 new_fam.set_wife(self._individuals[arguments[0]])
             elif tag == "CHIL":
                 new_fam.add_child(self._individuals[arguments[0]])
             elif tag == "MARR":
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 # print(level, tag, arguments)
                 try:
                     new_fam.set_marriedDate(arguments)
                 except:
                     continue
             elif tag == "DIV":
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 # print(level, tag, arguments)
                 try:
                     new_fam.set_divorcedDate(arguments)
                 except:
                     continue
Beispiel #13
0
 def test_siblings_spacing(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     t5 = Family("t5")
     t6 = Family("t6")
     p1 = Individual("p1")
     p1.set_birthDate((1990, 1, 1))
     p2 = Individual("p2")
     p2.set_birthDate((1990, 1, 1))
     p3 = Individual("p3")
     p3.set_birthDate((1990, 9, 1))
     p4 = Individual("p4")
     p4.set_birthDate((1990, 1, 2))
     p5 = Individual("p5")
     p5.set_birthDate((1990, 1, 3))
     p6 = Individual("p6")
     p6.set_birthDate((1990, 5, 30))
     # --------------------------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t2.add_child(p1)
     t2.add_child(p3)
     t3.add_child(p1)
     t3.add_child(p4)
     t4.add_child(p1)
     t4.add_child(p5)
     t5.add_child(p1)
     t5.add_child(p6)
     t6.add_child(p1)
     t6.add_child(p3)
     t6.add_child(p6)
     # --------------------------------------------------
     assert t1.siblings_spacing() == True
     assert t2.siblings_spacing() == True
     assert t3.siblings_spacing() == True
     assert t4.siblings_spacing() == False
     assert t5.siblings_spacing() == False
     assert t6.siblings_spacing() == False