Ejemplo n.º 1
0
 def incorrect_families(self):
     families = {
         "TEST1": Family("TEST1", [], None, None, date(2078, 10, 5), None),
         "TEST2": Family("TEST2", [], None, None, None, date(2076, 10, 5))
     }
     parser = TestParser({}, families)
     self.assertEqual(len(US01.dates_before_current_date(parser)), 2)
Ejemplo n.º 2
0
 def two_pair_twins_two_families(self):
     individuals = {
         'CHILD1': Individual(id='CHILD1',
                              birth=date(2005, 3, 10),
                              famc='FAM1'),
         'CHILD2': Individual(id='CHILD2',
                              birth=date(2006, 2, 23),
                              famc='FAM1'),
         'CHILD3': Individual(id='CHILD3',
                              birth=date(2009, 7, 20),
                              famc='FAM1'),
         'CHILD4': Individual(id='CHILD4',
                              birth=date(2009, 7, 20),
                              famc='FAM1'),
         'CHILD5': Individual(id='CHILD5',
                              birth=date(2007, 5, 5),
                              famc='FAM2'),
         'CHILD6': Individual(id='CHILD6',
                              birth=date(2007, 5, 5),
                              famc='FAM2')
     }
     families = {
         'FAM1':
         Family(id='FAM1',
                child_ids=['CHILD1', 'CHILD2', 'CHILD3', 'CHILD4']),
         'FAM2':
         Family(id='FAM2', child_ids=['CHILD5', 'CHILD6'])
     }
     parser = TestParser(individuals, families)
     db = TestDatabase(individuals, families)
     pt_list = US32.list_multiple_births(parser, db)
     self.assertEqual(len(pt_list), 1)
     self.assertEqual(TableHelpers.get_row_count(pt_list[0]), 2)
Ejemplo n.º 3
0
    def living_married(self):
        individuals = {
            "HUSB1": Individual(id="HUSB1", fams="FAM1"),
            "WIFE1": Individual(id="WIFE1", fams="FAM1"),
            "HUSB2": Individual(id="HUSB2", fams="FAM2"),
            "WIFE2": Individual(id="WIFE2", fams="FAM2"),
            "WIFE3": Individual(id="WIFE3", famc="FAM3"),
        }
        families = {
            "FAM1":
            Family(id="FAM1",
                   married=date(2012, 11, 12),
                   divorced=None,
                   husband_id="HUSB1",
                   wife_id="WIFE1"),
            "FAM2":
            Family(id="FAM2",
                   married=date(2012, 10, 16),
                   divorced=None,
                   husband_id="HUSB2",
                   wife_id="WIFE2"),
        }

        parser = TestParser(individuals, families)
        db = TestDatabase(individuals, families)
        pt_list = US30.list_living_married(parser, db)
        #print(pt_list)
        self.assertGreater(TableHelpers.get_row_count(pt_list[0]), 0)
Ejemplo n.º 4
0
 def one_table(self):
     marriage = date(2001, self.today.month, self.today.day)
     individuals = {}
     families = {
         "FAM1": Family(id="FAM1", married=DateHelpers.add_time(marriage, 15, "days")),
         "FAM2": Family(id="FAM2", married=DateHelpers.add_time(marriage, 16, "days")),
         "FAM3": Family(id="FAM3", married=DateHelpers.add_time(marriage, 1, "days")),
     }
     parser = TestParser(individuals, families)
     pt_list = US39.upcoming_anniversaries(parser)
     self.assertEqual(len(pt_list), 1)
Ejemplo n.º 5
0
 def two_anniversaries(self):
     marriage = date(2001, self.today.month, self.today.day)
     individuals = {}
     families = {
         "FAM1": Family(id="FAM1", married=DateHelpers.add_time(marriage, 15, "days")),
         "FAM2": Family(id="FAM2", married=DateHelpers.add_time(marriage, 16, "days")),
         "FAM3": Family(id="FAM3", married=DateHelpers.add_time(marriage, 100, "days")),
     }
     parser = TestParser(individuals, families)
     pt_list = US39.upcoming_anniversaries(parser)
     self.assertEqual(TableHelpers.get_row_count(pt_list[0]), 2)
Ejemplo n.º 6
0
 def nonUniqueIndiv(self):
     individuals = {
         "HUSB": Individual(id="SPOUSE", fams="FAM1", duplicates=1),
         "WIFE": Individual(id="SPOUSE", fams="FAM1"),
     }
     families = {
         "FAM1": Family(id="FAM1", married=date(2012,11,12), divorced=None, husband_id="HUSB", wife_id="WIFE1"),
         "FAM2": Family(id="FAM2", married=date(2012,10,16), divorced=None, husband_id="HUSB", wife_id="WIFE2"),
     }
     parser = TestParser(individuals, families)
     error_count = len(US22.unique_ids(parser))
     self.assertEqual(error_count, 1)
Ejemplo n.º 7
0
 def correct_null_dates(self):
     families = {
         "TEST1":
         Family("TEST1", None, None, None, married=None, divorced=None),
         "TEST1":
         Family("TEST1",
                None,
                None,
                None,
                married=date(2015, 10, 6),
                divorced=None),
     }
     parser = TestParser({}, families)
     self.assertEqual(len(US04.marriage_before_divorce(parser)), 0)
Ejemplo n.º 8
0
 def marriage_after_14(self):
     individuals = {
         "DAD":
         Individual("DAD",
                    name=None,
                    sex=None,
                    birth=date(1995, 11, 13),
                    death=None,
                    famc=None,
                    fams="FAM"),
         "MOM":
         Individual("MOM",
                    name=None,
                    sex=None,
                    birth=date(1997, 6, 20),
                    death=None,
                    famc=None,
                    fams="FAM")
     }
     families = {
         "FAM":
         Family("FAM",
                child_ids=[],
                husband_id="DAD",
                wife_id="MOM",
                married=date(2016, 8, 15),
                divorced=None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US10.marriage_after_14(parser)), 0)
Ejemplo n.º 9
0
 def male_last_names(self):
     individuals = {
         "HUSB":
         Individual(id="HUSB", name="Jim Halpert", sex="M", fams="FAM1"),
         "WIFE":
         Individual(id="WIFE", name="Pam Halpert", sex="F", fams="FAM2"),
         "CHILD":
         Individual(id="CHILD",
                    name="Michael Halpert",
                    sex="M",
                    famc="FAM1",
                    fams="FAM2"),
         "CHILD2":
         Individual(id="CHILD2",
                    name="Angela Halpert",
                    sex="F",
                    famc="FAM1",
                    fams="FAM2")
     }
     families = {
         "FAM1":
         Family(id="FAM",
                child_ids=["CHILD", "CHILD2"],
                husband_id="HUSB",
                wife_id="WIFE")
     }
     parser = TestParser(individuals, families)
     error_count = len(US16.male_last_name(parser))
     self.assertEqual(error_count, 0)
     pass
Ejemplo n.º 10
0
 def child_birth_at_marriage(self):
     individuals = {
         "DAD":
         Individual("DAD",
                    name=None,
                    sex=None,
                    birth=None,
                    death=None,
                    famc=None,
                    fams="FAM"),
         "MOM":
         Individual("MOM",
                    name=None,
                    sex=None,
                    birth=None,
                    death=None,
                    famc=None,
                    fams="FAM"),
         "SON":
         Individual("SON",
                    name=None,
                    sex=None,
                    birth=date(2010, 11, 6),
                    death=None,
                    famc="FAM",
                    fams=None),
     }
     families = {
         "FAM": Family("FAM", ["SON"], None, None, date(2010, 11, 6), None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US02.birth_before_marriage(parser)), 1)
Ejemplo n.º 11
0
 def incorrect_divorces(self):
     individuals = {
         "HUSB1":
         Individual("HUSB1",
                    name=None,
                    sex=None,
                    birth=None,
                    death=date(2013, 11, 6),
                    famc=None,
                    fams="TEST1"),
         "WIFE1":
         Individual("WIFE1",
                    name=None,
                    sex=None,
                    birth=None,
                    death=date(2015, 11, 6),
                    famc=None,
                    fams="TEST1")
     }
     families = {
         "TEST1": Family("TEST1", [], "HUSB1", "WIFE1", None,
                         date(2014, 10, 5))
     }
     parser = TestParser(individuals, families)
     self.assertGreater(len(US06.divorce_before_death(parser)), 0)
Ejemplo n.º 12
0
 def correctSeq(self):
     individuals = {
         "HUSB1":
         Individual("HUSB1",
                    name=None,
                    sex=None,
                    birth=None,
                    death=date(2015, 11, 6),
                    famc=None,
                    fams="TEST1"),
         "WIFE1":
         Individual("WIFE1",
                    name=None,
                    sex=None,
                    birth=None,
                    death=date(2015, 11, 6),
                    famc=None,
                    fams="TEST1")
     }
     families = {
         "TEST1": Family("TEST1", [], "HUSB1", "WIFE1", date(2014, 10, 5),
                         None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US05.marriage_before_death(parser)), 0)
Ejemplo n.º 13
0
 def no_married_siblings(self):
     individuals = {
         'I01':
         Individual('I01',
                    name='John',
                    sex=None,
                    birth=None,
                    death=None,
                    famc=None,
                    fams=None),
         'I02':
         Individual('I02',
                    name='Marie',
                    sex=None,
                    birth=None,
                    death=None,
                    famc=None,
                    fams=None),
         'I03':
         Individual('I03',
                    name='Robert',
                    sex=None,
                    birth=None,
                    death=None,
                    famc=None,
                    fams=None)
     }
     families = {
         'FAM1':
         Family('FAM1',
                child_ids=['I01', 'I03'],
                husband_id=None,
                wife_id=None,
                married=None,
                divorced=None),
         'FAM2':
         Family('FAM2',
                child_ids=[],
                husband_id='I01',
                wife_id='I02',
                married=None,
                divorced=None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US18.no_married_siblings(parser)), 0)
Ejemplo n.º 14
0
    def saveTagToObject(self, tagInstance):
        if tagInstance.level == 0 and tagInstance.tag not in [
                'HEAD', 'TRLR', 'NOTE'
        ]:
            id = tagInstance.args[0]

            if tagInstance.tag == 'INDI':
                if id in self.individuals:
                    self.individuals[id].duplicates += 1
                else:
                    self.individuals[id] = Individual(id)
            elif tagInstance.tag == 'FAM':
                if id in self.families:
                    self.families[id].duplicates += 1
                else:
                    self.families[id] = Family(id)
            # TODO do something with NOTE, HEAD, and TRLR
        elif tagInstance.tag not in ('BIRT, DEAT', 'MARR', 'DIV'):
            topLevelParent = tagInstance
            while topLevelParent.parent != None:
                topLevelParent = topLevelParent.parent

            if topLevelParent.tag == 'INDI':
                individual = self.individuals[topLevelParent.args[0]]

                if tagInstance.tag == 'NAME':
                    individual.name = ' '.join(tagInstance.args)
                elif tagInstance.tag == 'SEX':
                    individual.sex = tagInstance.args[0]
                elif tagInstance.tag == 'FAMC':
                    individual.famc = tagInstance.args[0]
                elif tagInstance.tag == 'FAMS':
                    individual.fams = tagInstance.args[0]
                elif tagInstance.tag == 'DATE':
                    date = GedcomParser.dateArgsToDate(tagInstance.args,
                                                       individual)
                    if tagInstance.parent.tag == 'BIRT':
                        individual.birth = date
                    elif tagInstance.parent.tag == 'DEAT':
                        individual.death = date
            elif topLevelParent.tag == 'FAM':
                family = self.families[topLevelParent.args[0]]

                if tagInstance.tag == 'HUSB':
                    family.husband_id = tagInstance.args[0]
                elif tagInstance.tag == 'WIFE':
                    family.wife_id = tagInstance.args[0]
                elif tagInstance.tag == 'CHIL':
                    family.child_ids.append(tagInstance.args[0])
                elif tagInstance.tag == 'DATE':
                    date = GedcomParser.dateArgsToDate(tagInstance.args,
                                                       family)
                    if tagInstance.parent.tag == 'MARR':
                        family.married = date
                    elif tagInstance.parent.tag == 'DIV':
                        family.divorced = date
Ejemplo n.º 15
0
 def no_siblings(self):
     individuals = {
         "WIFE": Individual(id="WIFE", fams="FAM"),
         "HUSB": Individual(id="HUSB", fams="FAM"),
     }
     families = {"FAM": Family(id="FAM")}
     parser = TestParser(individuals, families)
     db = TestDatabase(individuals, families)
     pt_list = US28.older_siblings_by_age(parser, db)
     self.assertEqual(len(pt_list), 0)
Ejemplo n.º 16
0
 def incorrect_marriages(self):
     individuals = {
         "HUSB": Individual(id="HUSB", fams="FAM1"),
         "WIFE": Individual(id="WIFE", fams="FAM2"),
         "CHILD": Individual(id="CHILD", famc="FAM1", fams="FAM2"),
     }
     families = {
         "FAM1":
         Family(id="FAM1",
                child_ids=["CHILD"],
                husband_id="HUSB",
                wife_id="WIFE"),
         "FAM2":
         Family(id="FAM2", husband_id="CHILD", wife_id="WIFE"),
     }
     parser = TestParser(individuals, families)
     db = TestDatabase(individuals, families)
     error_count = len(US17.no_marriages_to_children(parser, db))
     self.assertGreater(error_count, 0)
Ejemplo n.º 17
0
 def correct_families(self):
     families = {
         "TEST5":
         Family("TEST5",
                child_ids=[],
                husband_id=None,
                wife_id=None,
                married="1900-10-5",
                divorced="2002-1-31"),
         "TEST6":
         Family("TEST6",
                child_ids=[],
                husband_id=None,
                wife_id=None,
                married="1849-3-31",
                divorced="2011-4-30"),
     }
     parser = TestParser({}, families)
     self.assertEqual(len(US42.reject_illegitimate_dates(parser)), 0)
Ejemplo n.º 18
0
 def incorrect_families(self):
     families = {
         "TEST7":
         Family("TEST7",
                child_ids=[],
                husband_id=None,
                wife_id=None,
                married="1963-13-5",
                divorced="2016-1-32"),
         "TEST8":
         Family("TEST8",
                child_ids=[],
                husband_id=None,
                wife_id=None,
                married="2018-0-31",
                divorced="2018-2-30"),
     }
     parser = TestParser({}, families)
     self.assertEqual(len(US42.reject_illegitimate_dates(parser)), 4)
Ejemplo n.º 19
0
 def nullDadBirth(self):
     individuals = {
         "DAD": Individual("DAD", name=None, sex=None, birth=None, death=None, famc=None, fams="FAM"),
         "MOM": Individual("MOM", name=None, sex=None, birth=date(1985, 10, 6), death=None, famc=None, fams="FAM"),
         "CHILD": Individual("CHILD", name=None, sex=None, birth=date(2015, 10, 6), death=None, famc=None, fams="FAM")
     }
     families = {
         "FAM": Family("FAM", child_ids=["CHILD"], husband_id="DAD", wife_id="MOM", married=None, divorced=None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US12.parents_not_too_old(parser)), 0)
Ejemplo n.º 20
0
 def correct_gender_for_role(self):
     individuals = {
         "HUSB": Individual(id="HUSB", name="Jim", sex="M", fams="FAM1"),
         "WIFE": Individual(id="WIFE", name="Pam", sex="F", fams="FAM2"),
         "CHILD": Individual(id="CHILD", name="Dwight", sex="M", famc="FAM1", fams="FAM2"),
     }
     families = {
         "FAM1": Family(id="FAM", child_ids=["CHILD"], husband_id="HUSB", wife_id="WIFE")
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US21.correct_gender_for_role(parser)), 0)
Ejemplo n.º 21
0
 def correct(self):
     individuals = {
         "DAD": Individual("DAD", name=None, sex=None, birth=None, death=date(2017, 10, 6), famc=None, fams="FAM"),
         "MOM": Individual("MOM", name=None, sex=None, birth=None, death=date(2018, 10, 6), famc=None, fams="FAM"),
         "CHILD": Individual("CHILD", name=None, sex=None, birth=date(2015, 10, 6), death=None, famc=None, fams="FAM")
     }
     families = {
         "FAM": Family("FAM", child_ids=["CHILD"], husband_id="DAD", wife_id="MOM", married=None, divorced=None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US09.birth_before_parent_death(parser)), 0)
Ejemplo n.º 22
0
 def no_siblings(self):
     individuals = {
         "DAD": Individual("DAD", name=None, sex=None, birth=None, death=None, famc=None, fams="FAM"),
         "MOM": Individual("MOM", name=None, sex=None, birth=None, death=None, famc=None, fams="FAM"),
         "CHILD1": Individual("CHILD1", name=None, sex=None, birth=date(2013, 4, 14), death=None, famc="FAM", fams=None)
     }
     families = {
         "FAM": Family("FAM", child_ids=["CHILD1"], husband_id="DAD", wife_id="MOM", married=None, divorced=None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US13.sibling_spacing(parser)), 0)
Ejemplo n.º 23
0
 def incorrect_sequence(self):
     families = {
         "TEST1":
         Family("TEST1",
                None,
                None,
                None,
                married=date(2015, 10, 6),
                divorced=date(2015, 10, 5)),
     }
     parser = TestParser({}, families)
     self.assertGreater(len(US04.marriage_before_divorce(parser)), 0)
Ejemplo n.º 24
0
    def large_age_differences(self):
        individuals = {
            "HUSB1": Individual(id="HUSB1", birth=date(1967,9,30),fams="FAM1"),
            "WIFE1": Individual(id="WIFE1", birth=date(1989,7,31),fams="FAM1")
        }
        families = {
            "FAM1": Family(id="FAM1", married=date(2009,10,31), divorced=None, husband_id="HUSB1", wife_id="WIFE1")
        }

        parser = TestParser(individuals, families)
        db = TestDatabase(individuals, families)
        pt_list = US34.list_large_age_differences(parser, db)
        #print(pt_list[0])
        self.assertEqual(TableHelpers.get_row_count(pt_list[0]), 2)
Ejemplo n.º 25
0
    def not_large_age_differences(self):

        individuals = {
            "HUSB2": Individual(id="HUSB2", birth=date(1990,2,22),fams="FAM2"),
            "WIFE2": Individual(id="WIFE2", birth=date(1991,6,16),fams="FAM2")
        }
        families = {
            "FAM2": Family(id="FAM2", married=date(2012,10,16), divorced=None, husband_id="HUSB2", wife_id="WIFE2")
        }

        parser = TestParser(individuals, families)
        db = TestDatabase(individuals, families)
        pt_list = US34.list_large_age_differences(parser, db)
        #print(pt_list[0])
        self.assertEqual(TableHelpers.get_row_count(pt_list[0]), 0)
Ejemplo n.º 26
0
    def living_single(self):
        individuals = {
            "HUSB": Individual(id="HUSB", birth=date(1900, 2, 11), famc="FAM1"),
            "WIFE": Individual(id="WIFE", birth=date(1930, 4, 18), famc="FAM2"),
            "HUSB2": Individual(id="HUSB2", birth=date(2000, 8, 17),  fams="FAM2"),
            "WIFE2": Individual(id="WIFE2", birth=date(1990, 9, 26), fams="FAM2"),
        }
        families = {
             "FAM2": Family(id="FAM2", married=date(2012,10,16), divorced=None, husband_id="HUSB2", wife_id="WIFE2")
        }

        parser = TestParser(individuals, families)
        db = TestDatabase(individuals, families)
        pt_list = US31.list_living_single(parser, db)
        #print(pt_list)
        self.assertGreater(TableHelpers.get_row_count(pt_list[0]), 0)
Ejemplo n.º 27
0
 def noKids(self):
     individuals = {
         "CHILD1":
         Individual("CHILD1",
                    name=None,
                    sex=None,
                    birth=date(2014, 10, 5),
                    death=None,
                    famc=None,
                    fams=None)
     }
     families = {
         "TEST1": Family("TEST1", [], "TEST5", "TEST6", date(2015, 11, 6),
                         None)
     }
     parser = TestParser(individuals, families)
     self.assertEqual(len(US08.birth_before_parent_marriage(parser)), 0)
Ejemplo n.º 28
0
 def in_order(self):
     individuals = {
         "WIFE": Individual(id="WIFE", fams="FAM"),
         "HUSB": Individual(id="HUSB", fams="FAM"),
         "CHLD1": Individual(id="CHLD1", famc="FAM", birth=date(2001, 2,
                                                                1)),
         "CHLD2": Individual(id="CHLD2", famc="FAM", birth=date(2001, 2,
                                                                2)),
     }
     families = {"FAM": Family(id="FAM")}
     parser = TestParser(individuals, families)
     db = TestDatabase(individuals, families)
     pt_list = US28.older_siblings_by_age(parser, db)
     for index, row in enumerate(pt_list[0]):
         value = TableHelpers.get_row_field_value(row, "ID")
         if index == 0:
             self.assertEqual(value, "CHLD1")
         elif index == 1:
             self.assertEqual(value, "CHLD2")
Ejemplo n.º 29
0
 def no_multiple_births(self):
     individuals = {
         'CHILD1': Individual(id='CHILD1',
                              birth=date(2006, 1, 15),
                              famc='FAM1'),
         'CHILD2': Individual(id='CHILD2',
                              birth=date(2007, 6, 19),
                              famc='FAM1'),
         'CHILD3': Individual(id='CHILD3',
                              birth=date(2010, 4, 7),
                              famc='FAM1')
     }
     families = {
         'FAM1': Family(id='FAM1', child_ids=['CHILD1', 'CHILD2', 'CHILD3'])
     }
     parser = TestParser(individuals, families)
     db = TestDatabase(individuals, families)
     pt_list = US32.list_multiple_births(parser, db)
     self.assertEqual(len(pt_list), 1)
Ejemplo n.º 30
0
 def one_pair_twins(self):
     individuals = {
         'CHILD1': Individual(id='CHILD1',
                              birth=date(2006, 1, 15),
                              famc='FAM1'),
         'CHILD2': Individual(id='CHILD2',
                              birth=date(2007, 6, 19),
                              famc='FAM1'),
         'CHILD3': Individual(id='CHILD3',
                              birth=date(2007, 6, 19),
                              famc='FAM1')
     }
     families = {
         'FAM1': Family(id='FAM1', child_ids=['CHILD1', 'CHILD2', 'CHILD3'])
     }
     parser = TestParser(individuals, families)
     db = TestDatabase(individuals, families)
     pt_list = US32.list_multiple_births(parser, db)
     self.assertEqual(len(pt_list), 1)
     self.assertEqual(TableHelpers.get_row_count(pt_list[0]), 1)