def test_check_marr_b4_div(self):
            # Test check_marr_b4_div() function
            test_case_04_1 = Gedcom("./test_example_04_1")
            us04.check_marr_b4_div(test_case_04_1)
            test_case_04_1_expected = []
            self.assertEqual(test_case_04_1_expected,
                             test_case_04_1.error_list)

            test_case_04_2 = Gedcom("./test_example_04_2")
            us04.check_marr_b4_div(test_case_04_2)
            test_case_04_2_expected = []
            self.assertEqual(test_case_04_2_expected,
                             test_case_04_2.error_list)

            test_case_04_3 = Gedcom("./test_example_04_3")
            us04.check_marr_b4_div(test_case_04_3)
            test_case_04_3_expected = [
                'ERROR: FAMILY: US04: @F2@: Divorce date 1952-05-15 occurs before marriage date 1962-06-22'
            ]
            self.assertEqual(test_case_04_3_expected,
                             test_case_04_3.error_list)

            test_case_04_4 = Gedcom("./test_example_04_4")
            us04.check_marr_b4_div(test_case_04_4)
            test_case_04_4_expected = []
            self.assertEqual(test_case_04_4_expected,
                             test_case_04_4.error_list)
    def test_check_birth_b4_marr(self):
        # Test check_birth_b4_marr() function
        test_case_02_1 = Gedcom("sprint1test/test_example_02_1")
        us02.check_birth_b4_marr(test_case_02_1)
        test_case_02_1_expected = []
        self.assertEqual(test_case_02_1_expected, test_case_02_1.error_list)

        test_case_02_2 = Gedcom("sprint1test/test_example_02_2")
        us02.check_birth_b4_marr(test_case_02_2)
        test_case_02_2_expected = [
            'ERROR: FAMILY: US02: @F1@: @I1@: Marriage date 1925-06-08 occurs before birthday 1930-09-05',
            'ERROR: FAMILY: US02: @F1@: @I2@: Marriage date 1925-06-08 occurs before birthday 1932-07-01'
        ]
        self.assertEqual(test_case_02_2_expected, test_case_02_2.error_list)

        test_case_02_3 = Gedcom("sprint1test/test_example_02_3")
        us02.check_birth_b4_marr(test_case_02_3)
        test_case_02_3_expected = [
            'ERROR: FAMILY: US02: @F1@: @I1@: Marriage date 1931-06-08 occurs before birthday 1932-09-05'
        ]
        self.assertEqual(test_case_02_3_expected, test_case_02_3.error_list)

        test_case_02_4 = Gedcom("sprint1test/test_example_02_4")
        us02.check_birth_b4_marr(test_case_02_4)
        test_case_02_4_expected = [
            'ERROR: FAMILY: US02: @F1@: @I2@: Marriage date 1931-06-08 occurs before birthday 1932-07-01'
        ]
        self.assertEqual(test_case_02_4_expected, test_case_02_4.error_list)

        test_case_02_5 = Gedcom("sprint1test/test_example_02_5")
        us02.check_birth_b4_marr(test_case_02_5)
        test_case_02_5_expected = []
        self.assertEqual(test_case_02_5_expected, test_case_02_5.error_list)
예제 #3
0
def test_validate_no_marriage_to_children():
    """
  Testing US17
  """
    # Husband is married to child
    families = [
        Family('F01', wife_id='I02', husband_id='I01', children=['I03']),
        Family('F02', wife_id='I01', husband_id='I03')
    ]
    gedcom = Gedcom(individuals=[], families=families)
    errors = validation.validate_no_marriage_to_children(gedcom)
    assert len(errors) == 1
    assert errors[
        0] == 'Error: US17: Individiual I01 is married to I03, a child of theirs in Family F01.'

    # Wife is married to child
    families = [
        Family('F01', wife_id='I01', husband_id='I02', children=['I03']),
        Family('F02', wife_id='I01', husband_id='I03')
    ]
    gedcom = Gedcom(individuals=[], families=families)
    errors = validation.validate_no_marriage_to_children(gedcom)
    assert len(errors) == 1
    assert errors[
        0] == 'Error: US17: Individiual I01 is married to I03, a child of theirs in Family F01.'

    # No one is married to child
    families = [
        Family('F01', wife_id='I01', husband_id='I02', children=['I03'])
    ]
    gedcom = Gedcom(individuals=[], families=families)
    errors = validation.validate_no_marriage_to_children(gedcom)
    assert len(errors) == 0
    def test_check_birth_b4_death(self):
        # Test check_birth_b4_death() function
        test_case_03_1 = Gedcom("sprint1test/test_example_03_1")
        us03.check_birth_b4_death(test_case_03_1)
        test_case_03_1_expected = []
        self.assertEqual(test_case_03_1_expected, test_case_03_1.error_list)

        test_case_03_2 = Gedcom("sprint1test/test_example_03_2")
        us03.check_birth_b4_death(test_case_03_2)
        test_case_03_2_expected = [
            'ERROR: INDIVIDUAL: US03: @I1@: Death date 1930-09-05 occurs before Birthday 2008-01-01'
        ]
        self.assertEqual(test_case_03_2_expected, test_case_03_2.error_list)

        test_case_03_3 = Gedcom("sprint1test/test_example_03_3")
        us03.check_birth_b4_death(test_case_03_3)
        test_case_03_3_expected = [
            'ERROR: INDIVIDUAL: US03: @I2@: Death date 1932-07-01 occurs before Birthday 2015-05-05'
        ]
        self.assertEqual(test_case_03_3_expected, test_case_03_3.error_list)

        test_case_03_4 = Gedcom("sprint1test/test_example_03_4")
        us03.check_birth_b4_death(test_case_03_4)
        test_case_03_4_expected = []
        self.assertEqual(test_case_03_4_expected, test_case_03_4.error_list)

        test_case_03_5 = Gedcom("sprint1test/test_example_03_5")
        us03.check_birth_b4_death(test_case_03_5)
        test_case_03_5_expected = []
        self.assertEqual(test_case_03_5_expected, test_case_03_5.error_list)
    def test_check_marriage_after_14(self):
        test_case_10_1 = Gedcom("sprint2test/test_example_10_1")
        us10.check_marriage_after_14(test_case_10_1)
        test_case_10_1_expected = []
        self.assertEqual(test_case_10_1_expected, test_case_10_1.error_list)

        test_case_10_2 = Gedcom("sprint2test/test_example_10_2")
        us10.check_marriage_after_14(test_case_10_2)
        test_case_10_2_expected = ["ANOMALY: US10: FAMILY: @F1@: Wife: @I2@: Married at age: 12: On: 1945-06-08"]
        self.assertEqual(test_case_10_2_expected, test_case_10_2.error_list)
    def test_check_less_then_150_years_old(self):
        test_case_07_1 = Gedcom("sprint2test/test_example_07_1")
        us07.check_less_then_150_years_old(test_case_07_1)
        test_case_07_1_expected = ["ERROR: US07: INDIVIDUAL: " + "@I3@" + " is more than or equals to 150 years old."]
        self.assertEqual(test_case_07_1_expected, test_case_07_1.error_list)

        test_case_07_2 = Gedcom("sprint2test/test_example_07_2")
        us07.check_less_then_150_years_old(test_case_07_2)
        test_case_07_2_expected = []
        self.assertEqual(test_case_07_2_expected, test_case_07_2.error_list)
예제 #7
0
def test_validate_born_before_parents_death():
    """
    Test US09: Birth before death of parents (and not more than 9 months after death of father)
  """

    # Child born more than 9 months after father's death
    individuals = [
        Individual('I01',
                   birthday=datetime(year=2010, month=10, day=10),
                   child='F01'),
        Individual('I02', death=datetime(year=2008, month=10, day=10)),
        Individual('I03')
    ]
    families = [
        Family('F01', husband_id='I02', wife_id='I03', children=['I01'])
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.validate_born_before_parents_death(gedcom)
    assert len(errors) == 1
    assert errors[
        0] == 'Error: US09: Individual I01 born more than 9 months after death of their father, I02, in family F01'

    # Child born after mother's death
    individuals = [
        Individual('I01',
                   birthday=datetime(year=2010, month=10, day=10),
                   child='F01'),
        Individual('I02',
                   death=datetime(year=2010, month=8, day=10),
                   spouse='F01'),
        Individual('I03', spouse='F01')
    ]
    families = [
        Family('F01', husband_id='I03', wife_id='I02', children=['I01'])
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.validate_born_before_parents_death(gedcom)
    assert len(errors) == 1
    assert errors[
        0] == 'Error: US09: Individual I01 born after death of their mother, I02, in family F01'

    # Child born to parents not dead yet
    individuals = [
        Individual('I01',
                   birthday=datetime(year=2010, month=10, day=10),
                   child='F01'),
        Individual('I02', spouse='F01'),
        Individual('I03', spouse='F01')
    ]
    families = [
        Family('F01', husband_id='I02', wife_id='I03', children=['I01'])
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.validate_born_before_parents_death(gedcom)
    assert len(errors) == 0
예제 #8
0
def test_dates_before_current():
    # Marriage date after Today's date
    individuals = [
        Individual('I01', spouse='F01'),
        Individual('I02', spouse='F01')
    ]
    families = [
        Family('F01',
               wife_id='I01',
               husband_id='I02',
               married=datetime(2025, 10, 10))
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.validate_dates_before_current(gedcom)
    assert errors[
        0] == 'Error: US01: The Family F01\'s marriage date 2025-10-10 is after the current date'
    assert len(errors) == 1

    # Divorce date after Today's date
    individuals = [
        Individual('I01', spouse='F01'),
        Individual('I02', spouse='F01')
    ]
    families = [
        Family('F01',
               wife_id='I01',
               husband_id='I02',
               married=datetime(2000, 10, 10),
               divorced=datetime(2025, 10, 10))
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.validate_dates_before_current(gedcom)
    assert errors[
        0] == 'Error: US01: The Family F01\'s divorce date 2025-10-10 is after the current date'
    assert len(errors) == 1

    # Birthday after Today's date
    individual = [Individual('I01', birthday=datetime(2025, 10, 10))]
    gedcom = Gedcom(individuals=individual)
    errors = validation.validate_dates_before_current(gedcom)
    assert errors[
        0] == 'Error: US01: The Individual I01\'s birthday 2025-10-10 is after the current date'
    assert len(errors) == 1

    # Deathdate after Today's date
    individual = [
        Individual('I01',
                   birthday=datetime(1999, 10, 10),
                   death=datetime(2025, 10, 10))
    ]
    gedcom = Gedcom(individuals=individual)
    errors = validation.validate_dates_before_current(gedcom)
    assert errors[
        0] == 'Error: US01: The Individual I01\'s deathdate 2025-10-10 is after the current date'
    assert len(errors) == 1
 def test_check_parents_not_too_old(self):
     test_case_12_1 = Gedcom("sprint2test/test_example_12_1")
     us12.check_parents_not_too_old(test_case_12_1)
     test_case_12_1_expected = []
     self.assertEqual(test_case_12_1_expected, test_case_12_1.error_list)
     test_case_12_2 = Gedcom("sprint2test/test_example_12_2")
     us12.check_parents_not_too_old(test_case_12_2)
     test_case_12_2_expected = [
         'ANOMALY: US12: FAMILY: @F1@: Mother: @I2@ is more than 60 years older than her children: @I3@',
         'ANOMALY: US12: FAMILY: @F1@: Father: @I1@ is more than 80 years older than his children: @I3@']
     self.assertEqual(test_case_12_2_expected, test_case_12_2.error_list)
    def test_check_unique_id(self):
        test_case_22_1 = Gedcom("sprint2test/test_example_22_1")
        us22.check_unique_id(test_case_22_1)
        test_case_22_1_expected = []
        self.assertEqual(test_case_22_1_expected, test_case_22_1.error_list)

        test_case_22_2 = Gedcom("sprint2test/test_example_22_2")
        us22.check_unique_id(test_case_22_2)
        test_case_22_2_expected = ["ERROR: US22: FAMILY: @F1@ is not unique.",
                                   "ERROR: US22: INDIVIDUAL: @I1@ is not unique."]
        self.assertEqual(test_case_22_2_expected, test_case_22_2.error_list)
    def test_check_birth_b4_death_of_parents(self):
        test_case_09_1 = Gedcom("sprint2test/test_example_09_1")
        us09.check_birth_b4_death_of_parents(test_case_09_1)
        test_case_09_1_expected = []
        self.assertEqual(test_case_09_1_expected, test_case_09_1.error_list)

        test_case_09_2 = Gedcom("sprint2test/test_example_09_2")
        us09.check_birth_b4_death_of_parents(test_case_09_2)
        test_case_09_2_expected = ["ERROR: US09: FAMILY: @F1@: Child: @I5@: Birthday: 2009-05-14: "
                                   "After father: @I1@: Death: 2008-01-01: 9 months later"]
        self.assertEqual(test_case_09_2_expected, test_case_09_2.error_list)
예제 #12
0
    def test_check_unique_families_by_spouses(self):
        test_case_24_1 = Gedcom("sprint4test/test_example_24_1")
        us24.check_unique_families_by_spouses(test_case_24_1)
        test_case_24_1_expected = [
            "ERROR: US24: FAMILY: ['@F1@', '@F2@'] are duplicated."
        ]
        self.assertEqual(test_case_24_1_expected, test_case_24_1.error_list)

        test_case_24_2 = Gedcom("sprint4test/test_example_24_2")
        us24.check_unique_families_by_spouses(test_case_24_2)
        test_case_24_2_expected = []
        self.assertEqual(test_case_24_2_expected, test_case_24_2.error_list)
예제 #13
0
    def test_check_unique_name_and_birth_date(self):
        test_case_23_1 = Gedcom("sprint4test/test_example_23_1")
        us23.check_unique_name_and_birth_date(test_case_23_1)
        test_case_23_1_expected = [
            "ANOMALY: US23: INDIVIDUAL: ['@I1@', '@I2@'] are duplicated."
        ]
        self.assertEqual(test_case_23_1_expected, test_case_23_1.error_list)

        test_case_23_2 = Gedcom("sprint4test/test_example_23_2")
        us23.check_unique_name_and_birth_date(test_case_23_2)
        test_case_23_2_expected = []
        self.assertEqual(test_case_23_2_expected, test_case_23_2.error_list)
    def test_check_siblings_should_not_marry(self):
        test_case_18_1 = Gedcom("sprint3test/test_example_18_1")
        us18.check_siblings_should_not_marry(test_case_18_1)
        test_case_18_1_expected = [
            'ERROR: US18: FAMILY: @F2@, there is marriage between siblings.'
        ]
        self.assertEqual(test_case_18_1_expected, test_case_18_1.error_list)

        test_case_18_2 = Gedcom("sprint3test/test_example_18_2")
        us18.check_siblings_should_not_marry(test_case_18_2)
        test_case_18_2_expected = []
        self.assertEqual(test_case_18_2_expected, test_case_18_2.error_list)
    def test_check_no_marriages_to_descendants(self):
        test_case_17_1 = Gedcom("sprint3test/test_example_17_1")
        us17.check_no_marriages_to_descendants(test_case_17_1)
        test_case_17_1_expected = [
            'ERROR: US17: FAMILY: @F2@, there is marriage between parents and descendants.'
        ]
        self.assertEqual(test_case_17_1_expected, test_case_17_1.error_list)

        test_case_17_2 = Gedcom("sprint3test/test_example_17_2")
        us17.check_no_marriages_to_descendants(test_case_17_2)
        test_case_17_2_expected = []
        self.assertEqual(test_case_17_2_expected, test_case_17_2.error_list)
    def test_check_birth_b4_marriage_of_parents(self):
        test_case_08_1 = Gedcom("sprint2test/test_example_08_1")
        us08.check_birth_b4_marriage_of_parents(test_case_08_1)
        test_case_08_1_expected = ["ERROR: US08: FAMILY: " + "@F2@" + ": Child: " + "@I8@" +
                                   ": Birthday: " + "1945-04-16" +
                                   ": Before his/her parents' Married: " + "1982-05-15"]
        self.assertEqual(test_case_08_1_expected, test_case_08_1.error_list)

        test_case_08_2 = Gedcom("sprint2test/test_example_08_2")
        us08.check_birth_b4_marriage_of_parents(test_case_08_2)
        test_case_08_2_expected = []
        self.assertEqual(test_case_08_2_expected, test_case_08_2.error_list)
    def test_fewer_than_15_siblings(self):
        test_case_15_1 = Gedcom("sprint3test/test_example_15_1")
        us15.fewer_than_15_siblings(test_case_15_1)
        test_case_15_1_expected = []
        self.assertEqual(test_case_15_1_expected, test_case_15_1.error_list)

        test_case_15_2 = Gedcom("sprint3test/test_example_15_2")
        us15.fewer_than_15_siblings(test_case_15_2)
        test_case_16_2_expected = [
            "ANOMALY: US15: FAMILY: @F1@ has: 16 siblings, more than 15"
        ]
        self.assertEqual(test_case_16_2_expected, test_case_15_2.error_list)
    def test_male_last_names(self):
        test_case_16_1 = Gedcom("sprint3test/test_example_16_1")
        us16.male_last_names(test_case_16_1)
        test_case_16_1_expected = []
        self.assertEqual(test_case_16_1_expected, test_case_16_1.error_list)

        test_case_16_2 = Gedcom("sprint3test/test_example_16_2")
        us16.male_last_names(test_case_16_2)
        test_case_16_2_expected = [
            "ANOMALY: US16: FAMILY: @F1@: Male member: Elizabeth /Miller/: has different last names"
        ]
        self.assertEqual(test_case_16_2_expected, test_case_16_2.error_list)
    def test_check_date_b4_current(self):
        # Test check_date_b4_current() function
        test_case_01_1 = Gedcom("sprint1test/test_example_01_1")
        us01.check_date_b4_current(test_case_01_1)
        test_case_01_1_expected = [
            'ERROR: FAMILY: US01: @F2@: Divorced Date 2020-06-22 occurs before today: 2019-05-09'
        ]
        self.assertEqual(test_case_01_1_expected, test_case_01_1.error_list)

        test_case_01_2 = Gedcom("sprint1test/test_example_01_2")
        us01.check_date_b4_current(test_case_01_2)
        test_case_01_2_expected = []
        self.assertEqual(test_case_01_2_expected, test_case_01_2.error_list)
    def test_check_div_b4_death(self):
        # Test check_div_b4_death() function
        test_case_06_1 = Gedcom("sprint1test/test_example_06_1")
        us06.check_div_b4_death(test_case_06_1)
        test_case_06_1_expected = []
        self.assertEqual(test_case_06_1_expected, test_case_06_1.error_list)

        test_case_06_2 = Gedcom("sprint1test/test_example_06_2")
        us06.check_div_b4_death(test_case_06_2)
        test_case_06_2_expected = [
            'ERROR: FAMILY: US06: @F2@: Divorced date 2000-06-22 occurs before @I3@ Death date: 1998-01-01'
        ]
        self.assertEqual(test_case_06_2_expected, test_case_06_2.error_list)
예제 #21
0
    def test_unique_first_names_in_families(self):
        test_case_25_1 = Gedcom("sprint4test/test_example_25_1")
        us25.unique_first_names_in_families(test_case_25_1)
        test_case_25_1_expected = []
        self.assertEqual(test_case_25_1_expected, test_case_25_1.error_list)

        test_case_25_2 = Gedcom("sprint4test/test_example_25_2")
        us25.unique_first_names_in_families(test_case_25_2)
        test_case_25_2_expected = [
            "ANOMALY: US25: FAMILY: @F1@: Children: ['@I4@', '@I5@']: "
            "Has duplicated name and birthday"
        ]
        self.assertEqual(test_case_25_2_expected, test_case_25_2.error_list)
    def test_siblings_spacing(self):
        test_case_13_1 = Gedcom("sprint3test/test_example_13_1")
        us13.siblings_spacing(test_case_13_1)
        test_case_13_1_expected = [
            "ERROR: US13: Siblings: " + '@I5@' + " and " + '@I4@' +
            "s' birthdays are not more than 8 months apart or less than 2 days apart."
        ]
        self.assertEqual(test_case_13_1_expected, test_case_13_1.error_list)

        test_case_13_2 = Gedcom("sprint3test/test_example_13_2")
        us13.siblings_spacing(test_case_13_2)
        test_case_13_2_expected = []
        self.assertEqual(test_case_13_2_expected, test_case_13_2.error_list)
    def test_multiple_births_less_than_5(self):
        test_case_14_1 = Gedcom("sprint3test/test_example_14_1")
        us14.multiple_births_less_than_5(test_case_14_1)
        test_case_14_1_expected = [
            "ERROR: US14: 5 or more Siblings in family: " + '@F1@' +
            " have same birthdays."
        ]
        self.assertEqual(test_case_14_1_expected, test_case_14_1.error_list)

        test_case_14_2 = Gedcom("sprint3test/test_example_14_2")
        us14.multiple_births_less_than_5(test_case_14_2)
        test_case_14_2_expected = []
        self.assertEqual(test_case_14_2_expected, test_case_14_2.error_list)
    def test_check_marr_b4_death(self):
        # Test check_marr_b4_death() function
        test_case_05_1 = Gedcom("sprint1test/test_example_05_1")
        us05.check_marr_b4_death(test_case_05_1)
        test_case_05_1_expected = []
        self.assertEqual(test_case_05_1_expected, test_case_05_1.error_list)

        test_case_05_2 = Gedcom("sprint1test/test_example_05_2")
        us05.check_marr_b4_death(test_case_05_2)
        test_case_05_2_expected = [
            'ERROR: FAMILY: US03: @F1@: @I1@: Death date 2008-01-01 occurs before marriage date 2018-06-08',
            'ERROR: FAMILY: US03: @F1@: @I2@: Death date 2015-05-05 occurs before marriage date 2018-06-08'
        ]
        self.assertEqual(test_case_05_2_expected, test_case_05_2.error_list)
예제 #25
0
    def test_correct_gender_for_role(self):
        test_case_21_1 = Gedcom("sprint4test/test_example_21_1")
        us21.correct_gender_for_role(test_case_21_1)
        test_case_21_1_expected = [
            "ERROR: US21: FAMILY: @F1@: Husband: @I1@: Gender is not male"
        ]
        self.assertEqual(test_case_21_1_expected, test_case_21_1.error_list)

        test_case_21_2 = Gedcom("sprint4test/test_example_21_2")
        us21.correct_gender_for_role(test_case_21_2)
        test_case_21_2_expected = [
            "ERROR: US21: FAMILY: @F1@: Wife: @I2@: Gender is not female"
        ]
        self.assertEqual(test_case_21_2_expected, test_case_21_2.error_list)
예제 #26
0
def test_list_large_age_diff():
    """
        Test US34: List all couples who were married when the older spouse was more than twice as old as the younger spouse
    """
    # Wife is two times older on wedding day
    families = [
        Family('F01',
               married=datetime(2000, 1, 1),
               husband_id='I01',
               wife_id='I02')
    ]
    individuals = [
        Individual('I01',
                   name="John Smith",
                   birthday=datetime(1980, 1, 1),
                   spouses=['F01']),
        Individual('I02',
                   name="Abby Smith",
                   birthday=datetime(1940, 1, 1),
                   spouses=['F01'])
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.list_large_age_diff(gedcom)
    assert len(errors) == 1
    assert errors[
        0] == '(I02) Abby Smith was more than two times older than her husband (I01) John Smith when they got married on 2000-01-01'

    # Husband is two times older on wedding day
    families = [
        Family('F01',
               married=datetime(2000, 1, 1),
               husband_id='I01',
               wife_id='I02')
    ]
    individuals = [
        Individual('I01',
                   name="John Smith",
                   birthday=datetime(1940, 1, 1),
                   spouses=['F01']),
        Individual('I02',
                   name="Abby Smith",
                   birthday=datetime(1980, 1, 1),
                   spouses=['F01'])
    ]
    gedcom = Gedcom(individuals=individuals, families=families)
    errors = validation.list_large_age_diff(gedcom)
    assert len(errors) == 1
    assert errors[
        0] == '(I01) John Smith was more than two times older than his wife (I02) Abby Smith when they got married on 2000-01-01'
예제 #27
0
    def test_list_individual_ages(self):
        test_case_27_1 = Gedcom("sprint4test/test_example_32_1")
        temp_test = us27.list_individual_ages(test_case_27_1)
        test_case_27_1_expected = '''+-------+----------------------+-----+
|   ID  |         Name         | Age |
+-------+----------------------+-----+
|  @I1@ |  Jackson /Williams/  |  77 |
|  @I2@ |    Diana /Smith/     |  82 |
|  @I3@ |   John /Williams/    |  62 |
|  @I4@ | Jennifer /Williams/  |  53 |
|  @I5@ | Elizabeth /Williams/ |  53 |
| @I17@ |   Karen /Miller3/    |  53 |
| @I18@ |   Karen /Miller4/    |  53 |
| @I19@ |   Karen /Miller5/    |  53 |
|  @I6@ |    Sarah /Adams/     |  62 |
|  @I7@ |   Micheal /Davis/    |  64 |
|  @I8@ |  Steven /Williams/   |  34 |
|  @I9@ |   Charles /Davis/    |  22 |
| @I10@ |   Robert /Miller/    |  32 |
| @I11@ |    Karen /Miller/    |  28 |
| @I12@ |    Nancy /Miller/    |  26 |
| @I13@ |    Clark /Murphy/    |  53 |
| @I14@ |   Daniel /Murphy/    |  28 |
| @I15@ |   Ashley /Murphy/    |  25 |
| @I16@ |     Carol /Gray/     |  30 |
+-------+----------------------+-----+'''
        self.assertEqual(test_case_27_1_expected, temp_test)
예제 #28
0
파일: migrate.py 프로젝트: daonb/dbs-back
def migrate_trees(cursor, since_timestamp, until_timestamp, treenums):
    since = datetime.datetime.fromtimestamp(since_timestamp)
    until = datetime.datetime.fromtimestamp(until_timestamp)
    count = 0
    treenums = treenums.split(',') if treenums else None
        
    for row in sql_cursor:
        # special case for a specific tree
        if treenums:
            if str(row['GenTreeNumber']) not in treenums:
                continue
        elif row['UpdateDate'] < since or row['UpdateDate'] > until:
            continue
        file_id, file_name = get_file_descriptors(row)
        try:
            gedcom_fd = open(file_name)
        except IOError:
            logger.error('failed to open gedocm file tree number {}, path {}: {}'
                         .format(row['GenTreeNumber'], file_name, str(e)))
            continue

        try:
            g = Gedcom(fd=gedcom_fd)
        except (SyntaxError, GedcomParseError) as e:
            logger.error('failed to parse tree number {}, path {}: {}'
                         .format(row['GenTreeNumber'], file_name, str(e)))
            continue
        logger.info('>>> migrating tree {}, path {}'
                    .format(row['GenTreeNumber'], file_name))
        Gedcom2Persons(g, row['GenTreeNumber'], file_id, parse_n_update)
        logger.info('<<< migrated tree {}, path {}'
                    .format(row['GenTreeNumber'], file_name))
        count += 1
    return count
예제 #29
0
def migrate_trees(cursor, only_process_treenum=None, gedcom_path=None, on_save=None, dryrun=False):
    ''' get command line arguments and sql query and initiated update_tree
        and update_row celery tasks.
        returns how many people migrated
    '''
    collection_name = "persons"
    row_number = 0
    filtered_rows = filter(lambda row: not only_process_treenum or row['GenTreeNumber'] == only_process_treenum, cursor)
    for row_number, row in enumerate(filtered_rows, start=1):
        file_id, file_name = get_file_descriptors(row, gedcom_path)
        try:
            gedcom_fd = open(file_name)
        except IOError, e:
            logger.error('failed to open gedocm file tree number {}, path {}: {}'.format(row['GenTreeNumber'], file_name, str(e)))
        else:
            try:
                g = Gedcom(fd=gedcom_fd)
            except (SyntaxError, GedcomParseError) as e:
                logger.error('failed to parse tree number {}, path {}: {}'.format(row['GenTreeNumber'], file_name, str(e)))
            else:
                logger.info('>>> migrating tree {}, path {}'.format(row['GenTreeNumber'], file_name))
                if on_save and dryrun:
                    raise Exception("dryrun is not supported with on_save")
                else:
                    on_save = partial(parse_n_update, collection_name=collection_name, dryrun=dryrun) if not on_save else on_save
                    Gedcom2Persons(g, row['GenTreeNumber'], file_id, on_save)
                    logger.info('<<< migrated tree {}, path {}'.format(row['GenTreeNumber'], file_name))
예제 #30
0
def run_gedcom(input_url, output_url):
    run_case = Gedcom(input_url)
    run_case.set_output_url(output_url)
    run_case.print_pretty_table()

    us01.check_date_b4_current(run_case)
    us02.check_birth_b4_marr(run_case)
    us03.check_birth_b4_death(run_case)
    us04.check_marr_b4_div(run_case)
    us05.check_marr_b4_death(run_case)
    us06.check_div_b4_death(run_case)
    us07.check_less_then_150_years_old(run_case)
    us08.check_birth_b4_marriage_of_parents(run_case)
    us09.check_birth_b4_death_of_parents(run_case)
    us10.check_marriage_after_14(run_case)
    us12.check_parents_not_too_old(run_case)
    us22.check_unique_id(run_case)
    us13.siblings_spacing(run_case)
    us14.multiple_births_less_than_5(run_case)
    us15.fewer_than_15_siblings(run_case)
    us16.male_last_names(run_case)
    us17.check_no_marriages_to_descendants(run_case)
    us18.check_siblings_should_not_marry(run_case)
    us21.correct_gender_for_role(run_case)
    us23.check_unique_name_and_birth_date(run_case)
    us24.check_unique_families_by_spouses(run_case)
    us25.unique_first_names_in_families(run_case)

    output_stream = open(run_case.output_url, "a")
    output_stream.write("Errors:\n")
    for error in run_case.error_list:
        print(error)
        output_stream.write(error + '\n')
    output_stream.close()