Пример #1
0
 def test_strip_date(self):
     """ Tests that strip_date displays the correct error message with the expected line number. """
     with self.assertRaises(ValueError) as e:
         GED_Repo.strip_date(self, "40 JAN 1990", line_number=0).fail()
     self.assertEqual(
         "US42 - Illegitimate date of 40 JAN 1990. GEDCOM line: 0",
         str(e.exception))
Пример #2
0
    def test_check_user_story_35(self):
        """ Tests that user_story_35 list birth day in last 30 days. """

        # need following cases:
        # birthday within 30days 
        g = GED_Repo([os.path.join(os.getcwd(), 'test_directory', 'US35', 'US35_recent_births.ged')])
        self.assertEqual(g.user_story_35()._rows, [['@I1-US35-A@', 'Emith /Ohou/', datetime(2020, 3, 30, 0, 0).strftime("%m/%d/%Y")]])
Пример #3
0
def main():
    """ for running GED reader. """

    file_list = []
    # this will analyze all files in the input_files directory
    for folder in [
            x for x in os.listdir(os.path.join(os.getcwd(), 'test_directory'))
            if os.path.isdir(os.path.join(os.getcwd(), 'test_directory', x))
    ]:
        try:
            # print(f'Reading files in {folder}')
            file_list = file_list + [
                os.path.join(os.getcwd(), 'test_directory', folder, f)
                for f in os.listdir(
                    os.path.join(os.getcwd(), 'test_directory', folder))
                if f.endswith('.ged')
            ]
        except ValueError as v:
            print(v)
        except FileNotFoundError as f:
            print(f)

    try:
        print(f'Analyzing final cumulative file data.')
        # print(file_list)
        g = GED_Repo(file_list)
        g.check_data()
        g.print_data()
        g.print_individuals()
        g.print_families()
    except ValueError as v:
        print(v)
    except FileNotFoundError as f:
        print(f)
Пример #4
0
    def test_US31_living_single(self):
        """ Tests US31. Ensures that List living singles are printed to the user. """
        # single(age<30) is died
        g = GED_Repo([
            os.path.join(os.getcwd(), "test_directory", "US31",
                         "US31_died_less30_single.ged")
        ])
        self.assertEqual(g.US31_living_single(),
                         'No unmarried individuals over 30.')

        # single(age<30) is live
        g = GED_Repo([
            os.path.join(os.getcwd(), "test_directory", "US31",
                         "US31_liv_less30_single.ged")
        ])
        self.assertEqual(g.US31_living_single(),
                         'No unmarried individuals over 30.')

        # single(age>30) is live
        g = GED_Repo([
            os.path.join(os.getcwd(), "test_directory", "US31",
                         "US31_liv_over30_single.ged")
        ])
        pt = PrettyTable()
        pt.field_names = [
            'Unmarried Individual ID', 'Unmarried Individual Name'
        ]
        pt.add_row(['@I1-US31-A@', 'Libo /Tim_us31/'])
        pt.sortby = 'Unmarried Individual ID'
        self.assertEqual(pt._rows, g.US31_living_single()._rows)

        pass
Пример #5
0
 def test_user_story_15(self):
     """ Tests that Siblings should not marry one another """
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US18',
                      'US18_siblings_should_not_marry.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_18()
     sys.stdout = sys.__stdout__
     output_str1 = 'US18 - Martin /Johnson/ and Kristen /Johnson/ are siblings and are married on line 50\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #6
0
 def test_user_story_17(self):
     """ Tests that Parents should not marry any of their children """
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US17',
                      'US17_parents_should_not_marry_child.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_17()
     sys.stdout = sys.__stdout__
     output_str1 = 'US17 - Christine /Ponting/ and Brian /Ponting/ are married on line 52\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #7
0
 def test_user_story_21(self):
     """ Tests that husband gender is male and wife gender female and prints out the cases if not"""
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US21',
                      'US21_correct_gender_test.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_21()
     sys.stdout = sys.__stdout__
     output_str1 = 'US21 - Bella /Smith1/ gender is supposed to be female but is not on line 35\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #8
0
 def test_US34_Twice_age_diff(self):
     """ Tests US34. Ensures that List all couples who were married when the older spouse are printed to the user.  """
     # US34_test_married_diff
     g = GED_Repo([
         os.path.join(os.getcwd(), "test_directory", "US34",
                      "US34_test_married_diff.ged")
     ])
     pt = PrettyTable()
     pt.field_names = ['Family ID', 'Twice age diff married spouse']
     pt.add_row(['@F1_US34_A@', ('Limod /Desimy/', 'Simoy /Camd/')])
     pt.sortby = 'Family ID'
     self.assertEqual(pt._rows, g.US34_Twice_age_diff()._rows)
Пример #9
0
 def test_user_story_4(self):
     """ Tests that Marriage should occur before divorce of spouses, and divorce can only occur after marriage and rejects illegitimate data """
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US04',
                      'US04_marriage_before_divorce.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_4()
     sys.stdout = sys.__stdout__
     output_str1 = 'US04 - Jodie /John/ and Jimmy /John/ married after divorce on line 22\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #10
0
 def test_user_story_14(self):
     """ Tests that there are no more than 5 multiple births at the same time and prints out the cases if so"""
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US14',
                      'US14_multiple_births.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_14()
     sys.stdout = sys.__stdout__
     output_str1 = '''US14 - @F1-US14-EK@ has more than 5 multiple childrens born in the same time.\n'''
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #11
0
 def test_user_story_15(self):
     """ Tests that There should be fewer than 15 siblings in a family """
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US15',
                      'US15_less_than_15_siblings.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_15()
     sys.stdout = sys.__stdout__
     output_str1 = 'US15 - Bette /Mann5/ and Zepheniah /Mann5/ Family has 21 children on line 260\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #12
0
 def test_user_story_19(self):
     """ Tests that first cousins should not get married """
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US19',
                      'US19_first_cousins_should_not_marry_each_other.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_19()
     sys.stdout = sys.__stdout__
     output_str1 = 'US19 - Family @F5-US19-A@ is where first cousins are married\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #13
0
 def test_check_bday2(self):
     """ Tests that check_bday rejects illegitimate birthdays by throwing a ValueError. """
     # birth after father's death, outside 9 months (failure)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US09',
                      'US09_Birth_After_Death_Dad_Bad.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.check_bday()
     sys.stdout = sys.__stdout__
     output_str1 = 'US09 - Jimmy /John_1/ birthday after dads death date on line 21\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #14
0
    def test_user_story_12(self):
        """ Tests that there is no huge gap difference between father and child (<80) and mother and child (<60)  and prints out the cases if so"""
        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US12',
                         'US12_parents_not_too_old.ged')
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.user_story_12()
        sys.stdout = sys.__stdout__
        output_str1 = '''US12 - Rahim /Kaleci/ is 80 years older than his child on line 18
US12 - Sevdia /Meta/ is 60 years older than his child on line 27\n'''
        self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #15
0
    def test_user_story_11(self):
        """ Tests that husbands and wifes are not married twice at the same time and prints out the cases if so"""
        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US11',
                         'US11_no_bigamy.ged')
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.user_story_11()
        sys.stdout = sys.__stdout__
        output_str1 = '''US11 - Bledar /Hasa/ married twice on the same time on line 53
US11 - Ela /Zili/ married twice on the same time on line 62\n'''
        self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #16
0
    def test_user_story_10(self):
        """ Tests that check_bday rejects illegitimate Marriage days by throwing a ValueError. """

        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US10',
                         'US10_Marriage_Before_14.ged')
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.user_story_2()
        sys.stdout = sys.__stdout__
        output_str1 = 'US10 - Jodie /Hooke/ was less than 14 years old at time of marriage on line 30\nUS10 - Captain /Hooke/ was less than 14 years old at time of marriage on line 21\n'
        self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #17
0
 def test_check_bday4(self):
     """ Tests that check_bday rejects illegitimate birthdays by throwing a ValueError. """
     # birthday after divorce (within 9mo)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US08',
                      'US08_Birth_After_Divorce_Good.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.check_bday()
     sys.stdout = sys.__stdout__
     output_str1 = ''
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #18
0
 def test_check_bday3(self):
     """ Tests that check_bday rejects illegitimate birthdays by throwing a ValueError. """
     # birthday during marriage (normal case)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US08',
                      'US08_Birth_After_Marriage.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.check_bday()
     sys.stdout = sys.__stdout__
     output_str1 = ''
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #19
0
 def test_user_story_20(self):
     """ Tests that people should not marry their aunt or uncle """
     g = GED_Repo([
         os.path.join(
             os.getcwd(), 'test_directory', 'US20',
             'US20_aunts_uncles_should_not_marry_nephew_niece.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_20()
     sys.stdout = sys.__stdout__
     output_str1 = 'US20 - Family @F4-US20-A@ has someone married to their uncle\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #20
0
 def test_check_user_story_01_3(self):
     """ Tests that user_story_01 rejects illegitimate marriage day by throwing a ValueError. """
     # marriage day before today
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US01',
                      'US01_marriage_after_today.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_01()
     sys.stdout = sys.__stdout__
     output_str1 = 'US01 - Jaf /Jo4/ marriage after today on line 37\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #21
0
 def test_check_bday2(self):
     """ Tests that check_bday rejects illegitimate birthdays by throwing a ValueError. """
     # birthday after divorce (after 9mo)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US08',
                      'US08_Birth_After_Divorce_Bad.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.check_bday()
     sys.stdout = sys.__stdout__
     output_str1 = 'US08 - John /Smith6/ birthday before marriage on line 21\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #22
0
 def test_check_user_story_01_4(self):
     """ Tests that user_story_01 rejects illegitimate divorce day by throwing a ValueError. """
     # birthday after divorce (within 9mo)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US01',
                      'US01_divorce_after_today.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_01()
     sys.stdout = sys.__stdout__
     output_str1 = 'US01 - Jim /Jo3/ divorce after today on line 39\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #23
0
 def test_set_age2(self):
     """ Tests that set_age rejects illegitimate ages by throwing a ValueError. """
     # person under 150 (success)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US07',
                      'US07_Under_150.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.check_bday()
     sys.stdout = sys.__stdout__
     output_str1 = ''
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #24
0
 def test_set_age1(self):
     """ Tests that set_age rejects illegitimate ages by throwing a ValueError. """
     # person over 150 (failure)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US07',
                      'US07_Over_150.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.user_story_07()
     sys.stdout = sys.__stdout__
     output_str1 = 'US07 - Redmond /Mann3/ is age 159, which is over 150 years old, on line 24\n'
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #25
0
 def test_check_bday3(self):
     """ Tests that check_bday rejects illegitimate birthdays by throwing a ValueError. """
     # birth with both parents alive (success) (default)
     g = GED_Repo([
         os.path.join(os.getcwd(), 'test_directory', 'US09',
                      'US09_Birth_After_Death_Dad_Good.ged')
     ])
     capturedOutput = io.StringIO()
     sys.stdout = capturedOutput
     g.check_bday()
     sys.stdout = sys.__stdout__
     output_str1 = ''
     self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #26
0
    def test_check_bday1(self):
        """ Tests that check_bday rejects illegitimate birthdays by throwing a ValueError. """

        # need following cases:
        # birthday before marriage
        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US08',
                         'US08_Birth_Before_Marriage.ged')
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.check_bday()
        sys.stdout = sys.__stdout__
        output_str1 = 'US08 - Jim /Smith9/ birthday before marriage on line 39\n'
        self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #27
0
    def test_check_user_story_01(self):
        """ Tests that user_story_01 rejects illegitimate birth day by throwing a ValueError. """

        # need following cases:
        # birthday after today
        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US01',
                         'US01_birthday_after_today.ged')
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.user_story_01()
        sys.stdout = sys.__stdout__
        output_str1 = 'US01 - Jaf /Jo1/ birthday after today on line 21\n'
        self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #28
0
    def test_check_user_story_36(self):
        """ Tests that user_story_36 list who died in last 30 days. """

        # need following cases:
        # deathday within 30days
        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US36',
                         'US36_recent_deaths.ged')
        ])
        pt = PrettyTable()
        pt.field_names = [
            'Individual ID', 'Individual Name', 'Individual Death Date'
        ]
        pt.add_row(['@I1-US36-A@', 'Jaf /Jo7/', '03/31/2020'])
        self.assertEqual(g.user_story_36()._rows, pt._rows)
Пример #29
0
    def test_user_story_5(self):
        """ Tests that user_story_5 rejects illegitimate marriage by throwing a ValueError. """

        # need following cases:
        # marriage before death
        g = GED_Repo([
            os.path.join(os.getcwd(), 'test_directory', 'US05',
                         'US05_spr1.ged')
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.user_story_5()
        sys.stdout = sys.__stdout__
        output_str1 = 'US05 - Grey /Mann1/ married after individual death date on line 161\n'
        self.assertEqual(capturedOutput.getvalue(), output_str1)
Пример #30
0
    def test_US23_unique_name_and_birthdate(self):
        """ Tests US23. """
        self.maxDiff = None

        # duplicate name and birthdate
        g = GED_Repo([
            os.path.join(os.getcwd(), "test_directory", "US23",
                         "US23_Duplicate_Name_and_Birthdate.ged")
        ])
        capturedOutput = io.StringIO()
        sys.stdout = capturedOutput
        g.US23_unique_name_and_birthdate()
        sys.stdout = sys.__stdout__
        output_str1 = "US23: Two people with the same name and birthdate: ('Firstname /Lastname/', '01/01/1950') on GEDCOM line: 9 and ('Firstname /Lastname/', '01/01/1950') on GEDCOM line 15.\n"
        self.assertEqual(capturedOutput.getvalue(), output_str1)