コード例 #1
0
ファイル: test_us27.py プロジェクト: dhubinSIT/SSW555GEDCOM
 def test_birth_and_death(self):
     self.birthDeathIndi = Individual('@birthDeathIndi')
     self.birthDeathIndi.apply_value('BIRT', parse_date('1 JAN 2017'))
     self.birthDeathIndi.apply_value('DEAT', parse_date('31 DEC 2017'))
     self.assertEqual(0, self.birthDeathIndi.age)
     self.birthDeathIndi.apply_value('DEAT', parse_date('1 JAN 2018'))
     self.assertEqual(1, self.birthDeathIndi.age)
コード例 #2
0
ファイル: test_us03.py プロジェクト: dhubinSIT/SSW555GEDCOM
    def setUp(self):
        self.OkayIndi = Individual('@okay@')
        self.OkayIndi.apply_value('BIRT', parse_date('1 JUN 1945'))
        self.OkayIndi.apply_value('DEAT', parse_date('6 JAN 1995'))

        self.BadBirth = Individual('@birth@')
        self.BadBirth.apply_value('BIRT', parse_date('7 JAN 1995'))
        self.BadBirth.apply_value('DEAT', parse_date('6 JAN 1995'))
コード例 #3
0
 def setUp(self):
     self.OkayIndi1 = Individual('@okay1@')
     self.OkayIndi2 = Individual('@okay2@')
     self.OkayIndi1.apply_value('BIRT', parse_date('1 JUN 1945'))
     self.OkayIndi2.apply_value('BIRT', parse_date('1 JUN 1945'))
     self.OkayIndi1.apply_value('NAME', 'Prince William')
     self.OkayIndi2.apply_value('NAME', 'Princess Kate')
     self.OkayFam = Family('@okayf@')
     self.OkayFam.apply_value('CHIL', '@okay1@')
     self.OkayFam.apply_value('CHIL', '@okay2@')
コード例 #4
0
class US35TestCase(unittest.TestCase):
    def setUp(self):
        self.OkayIndi1 = Individual('@okay1@')
        self.OkayIndi1.apply_value('BIRT', parse_date('1 JUN 1985'))
        self.OkayIndi1.apply_value('NAME', 'Porky Pig')

    def test_US35_Listrecentbirths(self):
        """List of recent births."""
        recent_births = US35_Listrecentbirths({'@okay1@': self.OkayIndi1})

        self.assertFalse(self.OkayIndi1 in recent_births)
コード例 #5
0
    def setUp(self):
        self.HugeFamily = Family('@hugefam@')
        for x in range(1, 16):  # loops 15 times
            indi = Individual("@indi%d" % x)
            self.HugeFamily.apply_value("CHIL", "@indi%d")
            self.HugeFamily.add_child_ref(indi)

        self.ReasonableFamily = Family('@okayfam@')
        for x in range(1, 15):  # loops 14 times
            indi = Individual("@okayindi%d" % x)
            self.ReasonableFamily.apply_value("CHIL", "@okayindi%d")
            self.ReasonableFamily.add_child_ref(indi)
コード例 #6
0
ファイル: test_us31.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US31TestCase(unittest.TestCase):
    def setUp(self):
        self.OkayIndi1 = Individual('@okay1@')
        self.OkayIndi1.apply_value('BIRT', parse_date('1 JUN 1985'))
        self.OkayIndi1.apply_value('DEAT', parse_date('1 JUN 2015'))
        self.OkayIndi1.apply_value('NAME', 'Princess Kate')

    def test_US31_Listofliving(self):
        """List of Living."""
        Listofliving = US31_Listofliving({'@okay1@': self.OkayIndi1})

        self.assertFalse(self.OkayIndi1 in Listofliving)
コード例 #7
0
ファイル: test_us29.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US29TestCase(unittest.TestCase):
    def setUp(self):
        self.OkayIndi1 = Individual('@okay1@')
        self.OkayIndi1.apply_value('DEAT', parse_date('1 JUN 1945'))
        self.OkayIndi1.apply_value('NAME', 'Prince William')

    def test_US29_ListOfDeceased(self):
        """List of Deceased."""
        self.assertFalse(
            US29_ListOfDeceased({'@okay1@': self.OkayIndi1}) ==
            'Prince William')
        self.assertTrue(
            US29_ListOfDeceased({'@okay1@': self.OkayIndi1}) !=
            'Prince William')
コード例 #8
0
ファイル: test_us18.py プロジェクト: dhubinSIT/SSW555GEDCOM
    def setUp(self):
        self.brother = Individual('@brother@')
        self.brother.apply_value('FAMS', '@siblingFamily@')
        self.sister = Individual('@sister@')
        self.sister.apply_value('FAMS', '@siblingFamily@')
        self.mother = Individual('@mother@')
        self.father = Individual('@father@')
        self.child1 = Individual('@child@')
        self.childSpouse = Individual('@child1spouse@')

        self.parentFamily = Family('@parentFamily@')
        self.parentFamily.add_spouse_ref('HUSB', self.father)
        self.parentFamily.add_spouse_ref('WIFE', self.mother)
        self.parentFamily.apply_value('CHIL', '@brother@')
        self.parentFamily.add_child_ref(self.brother)
        self.parentFamily.apply_value('CHIL', '@sister@')
        self.parentFamily.add_child_ref(self.sister)

        self.siblingFamily = Family('@siblingFamily@')
        self.siblingFamily.apply_value('HUSB', '@brother@')
        self.siblingFamily.add_spouse_ref('HUSB', self.brother)
        self.siblingFamily.apply_value('HUSB', '@sister@')
        self.siblingFamily.add_spouse_ref('WIFE', self.sister)
        self.siblingFamily.apply_value('CHIL', '@child@')
        self.siblingFamily.add_child_ref(self.child1)

        self.grandkidsFamily = Family('@grandkids@')
        self.grandkidsFamily.apply_value('HUSB', '@child@')
        self.grandkidsFamily.add_spouse_ref('HUSB', self.child1)
        self.grandkidsFamily.apply_value('WIFE', '@child1spouse@')
        self.grandkidsFamily.add_spouse_ref('WIFE', self.childSpouse)
コード例 #9
0
    def setUp(self):
        self.OkayIndi = Individual('@okay@')
        self.OkayFam = Family('@okayf@')
        self.OkayIndi.apply_value('BIRT', parse_date('1 JUN 1945'))
        self.OkayIndi.apply_value('DEAT', parse_date('6 JAN 1995'))
        self.OkayFam.apply_value('MARR', parse_date('1 JUN 1975'))
        self.OkayFam.apply_value('HUSB', '@okay@')
        self.OkayFam.add_spouse_ref('HUSB', self.OkayIndi)

        self.BadBirth = Individual('@birth@')
        self.BadFam = Family('@badf@')
        self.BadBirth.apply_value('BIRT', parse_date('7 JAN 1995'))
        self.BadBirth.apply_value('DEAT', parse_date('6 JAN 1995'))
        self.BadFam.apply_value('MARR', parse_date('6 JAN 1995'))
        self.BadFam.apply_value('HUSB', '@birth@')
        self.BadFam.add_spouse_ref('HUSB', self.BadBirth)

        self.MissingBirth = Individual('@nobirth@')
        self.MissingBirthFam = Family('@badfnb@')
        self.MissingBirth.apply_value('DEAT', parse_date('6 JAN 1995'))
        self.MissingBirthFam.apply_value('MARR', parse_date('6 JAN 1995'))
        self.MissingBirthFam.apply_value('HUSB', '@nobirth@')
        self.MissingBirthFam.add_spouse_ref('HUSB', self.MissingBirth)

        self.MissingMarr = Individual('@nomarr@')
        self.MissingMarrFam = Family('@badfnm@')
        self.MissingMarr.apply_value('BIRT', parse_date('7 JAN 1995'))
        self.MissingMarr.apply_value('DEAT', parse_date('6 JAN 1995'))
        self.MissingMarrFam.apply_value('HUSB', '@nomarr@')
        self.MissingMarrFam.add_spouse_ref('HUSB', self.MissingMarr)
コード例 #10
0
 def setUp(self):
     """Set up a bunch of Individuals and Families with various future date issues
     (and some that are Okay)."""
     self.OkayIndi = Individual("@okay@")
     self.OkayIndi.apply_value("BIRT", parse_date("1 JUN 1945"))
     self.OkayIndi.apply_value("DEAT", parse_date("6 JAN 1995"))
     
     self.BadBirth = Individual("@birth@")
     self.BadBirth.apply_value("BIRT", parse_date("1 JAN 2525"))
     
     self.BadDeath = Individual("@death@")
     self.BadDeath.apply_value("BIRT", parse_date("1 JUN 1945"))
     self.BadDeath.apply_value("DEAT", parse_date("1 JAN 4545"))
     
     self.OkayFam = Family("@okayf@")
     self.OkayFam.apply_value("MARR", parse_date("15 SEP 1960"))
     self.OkayFam.apply_value("DIV", parse_date("15 SEP 1970"))
     
     self.BadMarr = Family("@badmarr@")
     self.BadMarr.apply_value("MARR", parse_date("15 SEP 2960"))
     
     self.BadDiv = Family("@baddiv@")
     self.BadDiv.apply_value("DIV", parse_date("15 SEP 2970"))
     
     self.DoubleBadIndi = Individual("@doubleIndi@")
     self.DoubleBadIndi.apply_value("BIRT", parse_date("1 JUN 3945"))
     self.DoubleBadIndi.apply_value("DEAT", parse_date("1 JAN 4545"))
     
     self.DoubleBadFam = Family("@doubleFam@")
     self.DoubleBadFam.apply_value("MARR", parse_date("15 SEP 2960"))
     self.DoubleBadFam.apply_value("DIV", parse_date("15 SEP 2970"))
コード例 #11
0
ファイル: test_us08.py プロジェクト: dhubinSIT/SSW555GEDCOM
    def setUp(self):
        self.OkayIndi = Individual('@okay@')
        self.OkayIndi.apply_value('BIRT', parse_date('1 JAN 2001'))

        self.BadIndiMarr = Individual('@badmarriage@')
        self.BadIndiMarr.apply_value('BIRT', parse_date('30 DEC 2000'))

        self.NoIndiBirth = Individual('@nobirth@')

        self.BadIndiDiv = Individual('@baddivorce@')
        self.BadIndiDiv.apply_value('BIRT', parse_date('5 OCT 2001'))

        self.MarrFam = Family('@marriedf@')
        self.MarrFam.apply_value('MARR', parse_date('1 JAN 2001'))        
        self.MarrFam.add_child_ref(self.OkayIndi)
        self.MarrFam.add_child_ref(self.BadIndiMarr)
        self.MarrFam.add_child_ref(self.NoIndiBirth)

        self.NoMarrFam = Family('@nomarriagef@')
        self.NoMarrFam.add_child_ref(self.OkayIndi)

        self.NoChildBirthFam = Family('@nochildbirthday@')
        self.NoChildBirthFam.add_child_ref(self.NoIndiBirth)

        self.NoDivFam = Family('@nodivorcef@')
        self.NoDivFam.add_child_ref(self.NoIndiBirth)

        self.DivFam = Family('@divorcedf@')
        self.DivFam.apply_value('DIV', parse_date('1 JAN 2001'))
        self.DivFam.add_child_ref(self.BadIndiDiv)
コード例 #12
0
ファイル: test_us18.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US18TestCase(unittest.TestCase):
    def setUp(self):
        self.brother = Individual('@brother@')
        self.brother.apply_value('FAMS', '@siblingFamily@')
        self.sister = Individual('@sister@')
        self.sister.apply_value('FAMS', '@siblingFamily@')
        self.mother = Individual('@mother@')
        self.father = Individual('@father@')
        self.child1 = Individual('@child@')
        self.childSpouse = Individual('@child1spouse@')

        self.parentFamily = Family('@parentFamily@')
        self.parentFamily.add_spouse_ref('HUSB', self.father)
        self.parentFamily.add_spouse_ref('WIFE', self.mother)
        self.parentFamily.apply_value('CHIL', '@brother@')
        self.parentFamily.add_child_ref(self.brother)
        self.parentFamily.apply_value('CHIL', '@sister@')
        self.parentFamily.add_child_ref(self.sister)

        self.siblingFamily = Family('@siblingFamily@')
        self.siblingFamily.apply_value('HUSB', '@brother@')
        self.siblingFamily.add_spouse_ref('HUSB', self.brother)
        self.siblingFamily.apply_value('HUSB', '@sister@')
        self.siblingFamily.add_spouse_ref('WIFE', self.sister)
        self.siblingFamily.apply_value('CHIL', '@child@')
        self.siblingFamily.add_child_ref(self.child1)

        self.grandkidsFamily = Family('@grandkids@')
        self.grandkidsFamily.apply_value('HUSB', '@child@')
        self.grandkidsFamily.add_spouse_ref('HUSB', self.child1)
        self.grandkidsFamily.apply_value('WIFE', '@child1spouse@')
        self.grandkidsFamily.add_spouse_ref('WIFE', self.childSpouse)

    def test_sibling_married(self):
        """Test a family where siblings are married to each other"""
        warns = self.parentFamily._Check_Siblings_Married_to_Each_Other()
        self.assertTrue(len(warns) == 1)
        self.assertTrue(warns[0].story == "US18")
        self.assertTrue('is married to a sibling' in warns[0].message)

    def test_normal_family(self):
        """Test a family where family kids are married normally"""
        warns = self.siblingFamily._Check_Siblings_Married_to_Each_Other()
        self.assertTrue(len(warns) == 0)
コード例 #13
0
 def setUp(self):
     self.Dupe1 = Individual('@dupe1@')
     self.Dupe1.apply_value('NAME', 'Danny /Dupe/')
     self.Dupe1.apply_value('BIRT', GedcomDate("1 JAN 1900"))
     self.Dupe2 = Individual('@dupe2@')
     self.Dupe2.apply_value('NAME', 'Danny /Dupe/')
     self.Dupe2.apply_value('BIRT', GedcomDate("1 JAN 1900"))
     self.OtherName = Individual('@name@')
     self.OtherName.apply_value('NAME', 'Danny /Duplicate/')
     self.OtherName.apply_value('BIRT', GedcomDate("1 JAN 1900"))
     self.OtherBirth = Individual('@birth@')
     self.OtherBirth.apply_value('NAME', 'Danny /Dupe/')
     self.OtherBirth.apply_value('BIRT', GedcomDate("1 JAN 1901"))
コード例 #14
0
ファイル: test_us21.py プロジェクト: dhubinSIT/SSW555GEDCOM
 def setUp(self):
     self.OddFamily = Family('@oddfam@')
     self.MasculineWoman = Individual('@wearspants@')
     self.MasculineWoman.apply_value("SEX",  "F")
     self.FeminineMan = Individual('@wearsskirts@')
     self.FeminineMan.apply_value("SEX",  "M")
     self.OddFamily.add_spouse_ref("HUSB", self.MasculineWoman)
     self.OddFamily.add_spouse_ref("WIFE", self.FeminineMan)
     
     self.ReasonableFamily = Family('@okayfam@')
     self.ManlyMan = Individual('@dude@')
     self.ManlyMan.apply_value('SEX', 'M')
     self.FeminineWoman = Individual('@lady@')
     self.FeminineWoman.apply_value('SEX', 'F')
     self.ReasonableFamily.add_spouse_ref("HUSB", self.ManlyMan)
     self.ReasonableFamily.add_spouse_ref("WIFE", self.FeminineWoman)
     
     self.UnknownFamily = Family('@blankfam@')
     self.OtherMan = Individual('@dude@')
     self.OtherLady = Individual('@lady@')
     self.UnknownFamily.add_spouse_ref("HUSB", self.OtherMan)
     self.UnknownFamily.add_spouse_ref("WIFE", self.OtherLady)
コード例 #15
0
ファイル: test_us09.py プロジェクト: dhubinSIT/SSW555GEDCOM
    def setUp(self):

        self.Mother = Individual('@okayMom@')
        self.Mother.apply_value('DEAT', parse_date('1 SEP 1995'))
        self.Father = Individual('@okayFather@')
        self.Father.apply_value('DEAT', parse_date('1 JAN 1995'))
        self.childafterMomDeath = Individual('@birthafterMomdeath@')
        self.childafterMomDeath.apply_value('BIRT', parse_date('2 SEP 1995'))
        self.childafterFatherDeath = Individual('@birthafterDaddeath@')
        self.childafterFatherDeath.apply_value('BIRT',
                                               parse_date('1 NOV 1995'))
        self.BadFam = Family('@badchildbirth@')
        self.BadFam.add_spouse_ref('HUSB', self.Father)
        self.BadFam.add_spouse_ref('WIFE', self.Mother)
        self.BadFam.add_child_ref(self.childafterMomDeath)
        self.BadFam.add_child_ref(self.childafterFatherDeath)
コード例 #16
0
class US28TestCase(unittest.TestCase):
    def setUp(self):
        self.OkayIndi1 = Individual('@okay1@')
        self.OkayIndi2 = Individual('@okay2@')
        self.OkayIndi1.apply_value('BIRT', parse_date('1 JUN 1945'))
        self.OkayIndi2.apply_value('BIRT', parse_date('1 JUN 1945'))
        self.OkayIndi1.apply_value('NAME', 'Prince William')
        self.OkayIndi2.apply_value('NAME', 'Princess Kate')
        self.OkayFam = Family('@okayf@')
        self.OkayFam.apply_value('CHIL', '@okay1@')
        self.OkayFam.apply_value('CHIL', '@okay2@')

    def test_US28_SiblingsByAge_pt(self):
        '''Test warnings if'''
        SiblingsAges = US28_SiblingsByAge(self.OkayFam.children_id_list,{'@okay1@' : self.OkayIndi1,'@okay2@': self.OkayIndi2},
                                         {'@okayf@' : self.OkayFam})
        self.assertEqual(SiblingsAges['Prince William'], 73)
        self.assertTrue(SiblingsAges['Princess Kate'] == 73)
コード例 #17
0
ファイル: test_us03.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US03TestCase(unittest.TestCase):
    def shortDescription(self):
        '''Disable printing docstring on verbose'''
        return None

    def setUp(self):
        self.OkayIndi = Individual('@okay@')
        self.OkayIndi.apply_value('BIRT', parse_date('1 JUN 1945'))
        self.OkayIndi.apply_value('DEAT', parse_date('6 JAN 1995'))

        self.BadBirth = Individual('@birth@')
        self.BadBirth.apply_value('BIRT', parse_date('7 JAN 1995'))
        self.BadBirth.apply_value('DEAT', parse_date('6 JAN 1995'))

    def test_birth_before_death(self):
        '''Test warnings if date of birth is after date of death'''
        warnings = self.BadBirth._Check_Birth_Before_Death()
        self.assertEqual(len(warnings), 1)
        self.assertTrue(
            '@birth@' in warnings[0].message
            and 'birth date after death date' in warnings[0].message)

    def test_okay_individual(self):
        '''Test warnings if date of birth is after date of death'''
        warnings = self.OkayIndi._Check_Birth_Before_Death()
        self.assertEqual(len(warnings), 0)

    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 3 MAR 1986
1 DEAT
2 DATE 3 MAR 1986
1 FAMS @F1@
0 @I2@ INDI
1 NAME MarvelousMay /Coffin/
1 SEX F
1 BIRT
2 DATE 3 MAR 1986
1 DEAT
2 DATE 2 MAR 1986
1 FAMS @F1@''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us03_errors = 0
        for warn in warnings:
            if warn.story == "US03": count_of_us03_errors += 1
        self.assertEqual(count_of_us03_errors, 1)
コード例 #18
0
ファイル: test_us21.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US21TestCase(unittest.TestCase):
    def setUp(self):
        self.OddFamily = Family('@oddfam@')
        self.MasculineWoman = Individual('@wearspants@')
        self.MasculineWoman.apply_value("SEX",  "F")
        self.FeminineMan = Individual('@wearsskirts@')
        self.FeminineMan.apply_value("SEX",  "M")
        self.OddFamily.add_spouse_ref("HUSB", self.MasculineWoman)
        self.OddFamily.add_spouse_ref("WIFE", self.FeminineMan)
        
        self.ReasonableFamily = Family('@okayfam@')
        self.ManlyMan = Individual('@dude@')
        self.ManlyMan.apply_value('SEX', 'M')
        self.FeminineWoman = Individual('@lady@')
        self.FeminineWoman.apply_value('SEX', 'F')
        self.ReasonableFamily.add_spouse_ref("HUSB", self.ManlyMan)
        self.ReasonableFamily.add_spouse_ref("WIFE", self.FeminineWoman)
        
        self.UnknownFamily = Family('@blankfam@')
        self.OtherMan = Individual('@dude@')
        self.OtherLady = Individual('@lady@')
        self.UnknownFamily.add_spouse_ref("HUSB", self.OtherMan)
        self.UnknownFamily.add_spouse_ref("WIFE", self.OtherLady)

    def test_questionable_family(self):
        """Test a family with a woman as a husband, and a man as a wife."""
        warns = self.OddFamily._Check_Familial_Roles()
        self.assertTrue(len(warns) == 2)
        self.assertTrue(len([x for x in warns if x.story == "US21" and "@wearspants@" in x.message and "Husband" in x.message]) == 1)
        self.assertTrue(len([x for x in warns if x.story == "US21" and "@wearsskirts@" in x.message and "Wife" in x.message]) == 1)

    def test_okay_family(self):
        """Test a family with normal husband/wife gender roles."""
        warns = self.ReasonableFamily._Check_Familial_Roles()
        self.assertTrue(len(warns) == 0)
        
    def test_unknown_family(self):
        """Test a family with blank gender identities (don't warn)."""
        warns = self.UnknownFamily._Check_Familial_Roles()
        self.assertTrue(len(warns) == 0)
コード例 #19
0
ファイル: test_us12.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US12TestCase(unittest.TestCase):
    def setUp(self):
        self.OldFamily = Family('@oldfam@')
        self.OldFather = Individual('@oldfart@')
        self.OldFather.apply_value('BIRT', GedcomDate("01 JAN 1900"))
        self.OldMother = Individual('@oldtart@')
        self.OldMother.apply_value('BIRT', GedcomDate("01 JAN 1920"))
        self.ChildOfOld = Individual("@oldchild@")
        self.ChildOfOld.apply_value('BIRT',  GedcomDate("02 JAN 1980"))
        self.OldFamily.add_spouse_ref("HUSB", self.OldFather)
        self.OldFamily.add_spouse_ref("WIFE", self.OldMother)
        self.OldFamily.add_child_ref(self.ChildOfOld)
        
        self.ReasonableFamily = Family('@okayfam@')
        self.YngFather = Individual('@oldfart@')
        self.YngFather.apply_value('BIRT', GedcomDate("01 JAN 1900"))
        self.YngMother = Individual('@oldtart@')
        self.YngMother.apply_value('BIRT', GedcomDate("01 JAN 1920"))
        self.ChildOfYng = Individual("@oldchild@")
        self.ChildOfYng.apply_value('BIRT',  GedcomDate("31 DEC 1979"))
        self.ReasonableFamily.add_spouse_ref("HUSB", self.YngFather)
        self.ReasonableFamily.add_spouse_ref("WIFE", self.YngMother)
        self.ReasonableFamily.add_child_ref(self.ChildOfYng)

    def test_old_family(self):
        """Test a child born when father 80 years and mother 60 years old.
        Note, using 02 JAN because of leap year rounding."""
        warns = self.OldFamily._Check_Parent_Child_Relative_Ages()
        self.assertTrue(len(warns) == 2)
        self.assertTrue(len([x for x in warns if x.story == "US12" and "@oldfart@" in x.message and "@oldchild" in x.message and "Father" in x.message]) == 1)
        self.assertTrue(len([x for x in warns if x.story == "US12" and "@oldtart@" in x.message and "@oldchild" in x.message and "Mother" in x.message]) == 1)

    def test_okay_family(self):
        """Test a child born when father 80 years (less one day) and mother 60 years old (less one day)."""
        warns = self.ReasonableFamily._Check_Parent_Child_Relative_Ages()
        self.assertTrue(len(warns) == 0)
コード例 #20
0
ファイル: test_us29.py プロジェクト: dhubinSIT/SSW555GEDCOM
 def setUp(self):
     self.OkayIndi1 = Individual('@okay1@')
     self.OkayIndi1.apply_value('DEAT', parse_date('1 JUN 1945'))
     self.OkayIndi1.apply_value('NAME', 'Prince William')
コード例 #21
0
ファイル: test_us12.py プロジェクト: dhubinSIT/SSW555GEDCOM
 def setUp(self):
     self.OldFamily = Family('@oldfam@')
     self.OldFather = Individual('@oldfart@')
     self.OldFather.apply_value('BIRT', GedcomDate("01 JAN 1900"))
     self.OldMother = Individual('@oldtart@')
     self.OldMother.apply_value('BIRT', GedcomDate("01 JAN 1920"))
     self.ChildOfOld = Individual("@oldchild@")
     self.ChildOfOld.apply_value('BIRT',  GedcomDate("02 JAN 1980"))
     self.OldFamily.add_spouse_ref("HUSB", self.OldFather)
     self.OldFamily.add_spouse_ref("WIFE", self.OldMother)
     self.OldFamily.add_child_ref(self.ChildOfOld)
     
     self.ReasonableFamily = Family('@okayfam@')
     self.YngFather = Individual('@oldfart@')
     self.YngFather.apply_value('BIRT', GedcomDate("01 JAN 1900"))
     self.YngMother = Individual('@oldtart@')
     self.YngMother.apply_value('BIRT', GedcomDate("01 JAN 1920"))
     self.ChildOfYng = Individual("@oldchild@")
     self.ChildOfYng.apply_value('BIRT',  GedcomDate("31 DEC 1979"))
     self.ReasonableFamily.add_spouse_ref("HUSB", self.YngFather)
     self.ReasonableFamily.add_spouse_ref("WIFE", self.YngMother)
     self.ReasonableFamily.add_child_ref(self.ChildOfYng)
コード例 #22
0
ファイル: test_us08.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US08TestCase(unittest.TestCase):
    def shortDescription(self):
        '''Disable printing docstring on verbose'''
        return None

    def setUp(self):
        self.OkayIndi = Individual('@okay@')
        self.OkayIndi.apply_value('BIRT', parse_date('1 JAN 2001'))

        self.BadIndiMarr = Individual('@badmarriage@')
        self.BadIndiMarr.apply_value('BIRT', parse_date('30 DEC 2000'))

        self.NoIndiBirth = Individual('@nobirth@')

        self.BadIndiDiv = Individual('@baddivorce@')
        self.BadIndiDiv.apply_value('BIRT', parse_date('5 OCT 2001'))

        self.MarrFam = Family('@marriedf@')
        self.MarrFam.apply_value('MARR', parse_date('1 JAN 2001'))        
        self.MarrFam.add_child_ref(self.OkayIndi)
        self.MarrFam.add_child_ref(self.BadIndiMarr)
        self.MarrFam.add_child_ref(self.NoIndiBirth)

        self.NoMarrFam = Family('@nomarriagef@')
        self.NoMarrFam.add_child_ref(self.OkayIndi)

        self.NoChildBirthFam = Family('@nochildbirthday@')
        self.NoChildBirthFam.add_child_ref(self.NoIndiBirth)

        self.NoDivFam = Family('@nodivorcef@')
        self.NoDivFam.add_child_ref(self.NoIndiBirth)

        self.DivFam = Family('@divorcedf@')
        self.DivFam.apply_value('DIV', parse_date('1 JAN 2001'))
        self.DivFam.add_child_ref(self.BadIndiDiv)


    def test_birth_before_marr(self):
        '''Test warnings if date of birth is before date of parents marriage'''
        warnings = self.MarrFam._Check_Children_Birth_After_Marriage()
        self.assertEqual(len(warnings), 1)
        self.assertTrue('@badmarriage@' in warnings[0].message and 'was born before Parents marriage date' in warnings[0].message)

    def test_no_marr(self):
        '''Test warnings if no date of marriage'''
        warnings = self.NoMarrFam._Check_Children_Birth_After_Marriage()
        self.assertEqual(len(warnings), 0)

    def test_no_birth(self):
        '''Test warnings if no date of birth'''
        warnings = self.NoChildBirthFam._Check_Children_Birth_After_Marriage()
        self.assertEqual(len(warnings), 0)

    def test_no_div(self):
        '''Test warnings if no date of divorce'''
        warnings = self.NoDivFam._Check_Children_Birth_After_Divorce()
        self.assertEqual(len(warnings), 0)

    def test_birth_after_div(self):
        '''Test warnings if date of birth is nine months after date of parents divorce'''
        warnings = self.DivFam._Check_Children_Birth_After_Divorce()
        self.assertEqual(len(warnings), 1)
        self.assertTrue('@baddivorce@' in warnings[0].message and 'was born nine months after Parents divorce date' in warnings[0].message)

    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 6 OCT 1986
1 FAMS @F1@
0 @I2@ INDI
1 NAME SomethingSally /Coffin/
1 SEX F
1 BIRT
2 DATE 30 DEC 1985
1 FAMS @F1@
0 @F1@ FAM
1 MARR
2 DATE 1 JAN 1986
1 DIV
2 DATE 2 JAN 1986
1 CHIL @I1@
1 CHIL @I2@
''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us08_errors = 0
        for warn in warnings:
            if warn.story == "US08": count_of_us08_errors += 1
        self.assertEqual(count_of_us08_errors, 2)
コード例 #23
0
class US05TestCase(unittest.TestCase):
    def shortDescription(self):
        '''Disable printing docstring on verbose'''
        return None

    def setUp(self):
        self.OkayIndi = Individual('@okay@')
        self.OkayFam = Family('@okayf@')
        self.OkayIndi.apply_value('DEAT', parse_date('6 JAN 1995'))
        self.OkayFam.apply_value('MARR', parse_date('1 JUN 1975'))
        self.OkayFam.apply_value('HUSB', '@okay@')
        self.OkayFam.add_spouse_ref('HUSB', self.OkayIndi)

        self.BadDeath = Individual('@death@')
        self.BadFam = Family('@badf@')
        self.BadDeath.apply_value('DEAT', parse_date('5 JAN 1995'))
        self.BadFam.apply_value('MARR', parse_date('6 JAN 1995'))
        self.BadFam.apply_value('HUSB', '@death@')
        self.BadFam.add_spouse_ref('HUSB', self.BadDeath)

        self.MissingDeath = Individual('@nodeath@')
        self.MissingDeathFam = Family('@badfnd@')
        self.MissingDeathFam.apply_value('MARR', parse_date('6 JAN 1995'))
        self.MissingDeathFam.apply_value('HUSB', '@nodeath@')
        self.MissingDeathFam.add_spouse_ref('HUSB', self.MissingDeath)

        self.MissingMarr = Individual('@nomarr@')
        self.MissingMarrFam = Family('@badfnm@')
        self.MissingMarr.apply_value('DEAT', parse_date('6 JAN 1995'))
        self.MissingMarrFam.apply_value('HUSB', '@nomarr@')
        self.MissingMarrFam.add_spouse_ref('HUSB', self.MissingMarr)

    def test_death_before_marr(self):
        '''Test warnings if date of death is before date of marriage'''
        warnings = _US05_Death_Before_Marriage(
            {
                '@okay@': self.OkayIndi,
                '@death@': self.BadDeath
            }, {
                '@okayf@': self.OkayFam,
                '@badf@': self.BadFam
            })
        self.assertEqual(len(warnings), 1)
        self.assertTrue(
            '@death@' in warnings[0].message
            and 'death date before marriage date' in warnings[0].message)

    def test_no_death(self):
        '''Test warnings if no date of death'''
        warnings = _US05_Death_Before_Marriage(
            {
                '@okay@': self.OkayIndi,
                '@nodeath@': self.MissingDeath
            }, {
                '@okayf@': self.OkayFam,
                '@badfnd@': self.MissingDeathFam
            })
        self.assertEqual(len(warnings), 0)

    def test_no_marriage(self):
        '''Test warnings if no date of marriage'''
        warnings = _US05_Death_Before_Marriage(
            {
                '@okay@': self.OkayIndi,
                '@nomarr@': self.MissingMarr
            }, {
                '@okayf@': self.OkayFam,
                '@badfnm@': self.MissingMarrFam
            })
        self.assertEqual(len(warnings), 0)

    def test_okay_individual(self):
        '''Test warnings if date of birth is after date of death'''
        warnings = _US05_Death_Before_Marriage({'@okay@': self.OkayIndi},
                                               {'@okayf@': self.OkayFam})
        self.assertEqual(len(warnings), 0)

    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 3 MAR 1986
1 DEAT
2 DATE 3 MAR 1986
1 FAMS @F1@
0 @I2@ INDI
1 NAME SomethingSally /Coffin/
1 SEX F
1 BIRT
2 DATE 1 MAR 1986
1 DEAT
2 DATE 1 MAR 1986
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I1@
1 WIFE @I2@
1 MARR
2 DATE 2 MAR 1986''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us05_errors = 0
        for warn in warnings:
            if warn.story == "US05": count_of_us05_errors += 1
        self.assertEqual(count_of_us05_errors, 1)
コード例 #24
0
ファイル: test_us09.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US09TestCase(unittest.TestCase):
    def shortDescription(self):
        '''Disable printing docstring on verbose'''
        return None

    def setUp(self):

        self.Mother = Individual('@okayMom@')
        self.Mother.apply_value('DEAT', parse_date('1 SEP 1995'))
        self.Father = Individual('@okayFather@')
        self.Father.apply_value('DEAT', parse_date('1 JAN 1995'))
        self.childafterMomDeath = Individual('@birthafterMomdeath@')
        self.childafterMomDeath.apply_value('BIRT', parse_date('2 SEP 1995'))
        self.childafterFatherDeath = Individual('@birthafterDaddeath@')
        self.childafterFatherDeath.apply_value('BIRT',
                                               parse_date('1 NOV 1995'))
        self.BadFam = Family('@badchildbirth@')
        self.BadFam.add_spouse_ref('HUSB', self.Father)
        self.BadFam.add_spouse_ref('WIFE', self.Mother)
        self.BadFam.add_child_ref(self.childafterMomDeath)
        self.BadFam.add_child_ref(self.childafterFatherDeath)

    def test_birth_after_parents_death(self):
        '''Test warnings if date of birth is after death of parents'''
        warnings = self.BadFam._Check_Children_Birth_Before_Parent_Death()
        self.assertEqual(len(warnings), 3)
        self.assertTrue(
            '@birthafterMomdeath@' in warnings[0].message
            and 'was born after Mothers death' in warnings[0].message)
        self.assertTrue(
            '@birthafterDaddeath@' in warnings[1].message
            and 'was born after Mothers death' in warnings[1].message)
        self.assertTrue('@birthafterDaddeath@' in warnings[2].message
                        and 'was born nine months after Fathers death'
                        in warnings[2].message)

    def test_full_path(self):
        '''Integration test for parser->objects->validation'''
        buff = StringIO('''0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 DEAT
2 DATE 1 SEP 1995
0 @I2@ INDI
1 NAME SomethingSally /Coffin/
1 DEAT
2 DATE 1 JAN 1995
0 @I3@ INDI
1 NAME Maddye /Simmons/
1 BIRT
2 DATE 2 SEP 1995
0 @I4@ INDI
1 NAME Derek /Simmons/
1 BIRT
2 DATE 1 NOV 1995
0 @F1@ FAM
1 HUSB @I2@
1 WIFE @I1@
1 CHIL @I3@
1 CHIL @I4@''')
        (ind, fam, unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind, fam)
        count_of_us09_errors = 0
        for warn in warnings:
            if warn.story == "US09": count_of_us09_errors += 1
        self.assertEqual(count_of_us09_errors, 3)
コード例 #25
0
ファイル: test_us27.py プロジェクト: dhubinSIT/SSW555GEDCOM
 def test_birth(self):
     self.birthIndi = Individual('@birthIndi')
     self.birthIndi.apply_value('BIRT', datetime.now() - timedelta(days = 364))
     self.assertEqual(0, self.birthIndi.age)
     self.birthIndi.apply_value('BIRT', datetime.now() - timedelta(days = 365))
     self.assertEqual(1, self.birthIndi.age)
コード例 #26
0
ファイル: test_us27.py プロジェクト: dhubinSIT/SSW555GEDCOM
 def test_missing_birth_and_death(self):
     self.missingDetailsIndi = Individual('@missingDetails')
     self.missingDetailsIndi._update_individual_age()
     self.assertEqual(None, self.missingDetailsIndi.age)
コード例 #27
0
ファイル: test_us27.py プロジェクト: dhubinSIT/SSW555GEDCOM
class US27TestCase(unittest.TestCase):
    def shortDescription(self):
        """Disable printing docstring on verbose."""
        return None
    
    def test_missing_birth_and_death(self):
        self.missingDetailsIndi = Individual('@missingDetails')
        self.missingDetailsIndi._update_individual_age()
        self.assertEqual(None, self.missingDetailsIndi.age)

    def test_birth_and_death(self):
        self.birthDeathIndi = Individual('@birthDeathIndi')
        self.birthDeathIndi.apply_value('BIRT', parse_date('1 JAN 2017'))
        self.birthDeathIndi.apply_value('DEAT', parse_date('31 DEC 2017'))
        self.assertEqual(0, self.birthDeathIndi.age)
        self.birthDeathIndi.apply_value('DEAT', parse_date('1 JAN 2018'))
        self.assertEqual(1, self.birthDeathIndi.age)

    def test_birth(self):
        self.birthIndi = Individual('@birthIndi')
        self.birthIndi.apply_value('BIRT', datetime.now() - timedelta(days = 364))
        self.assertEqual(0, self.birthIndi.age)
        self.birthIndi.apply_value('BIRT', datetime.now() - timedelta(days = 365))
        self.assertEqual(1, self.birthIndi.age)
コード例 #28
0
 def setUp(self):
     self.OkayIndi1 = Individual('@okay1@')
     self.OkayIndi1.apply_value('BIRT', parse_date('1 JUN 1985'))
     self.OkayIndi1.apply_value('NAME', 'Porky Pig')
コード例 #29
0
class US01TestCase(unittest.TestCase):
    def shortDescription(self):
        """Disable printing docstring on verbose."""
        return None
        
    def setUp(self):
        """Set up a bunch of Individuals and Families with various future date issues
        (and some that are Okay)."""
        self.OkayIndi = Individual("@okay@")
        self.OkayIndi.apply_value("BIRT", parse_date("1 JUN 1945"))
        self.OkayIndi.apply_value("DEAT", parse_date("6 JAN 1995"))
        
        self.BadBirth = Individual("@birth@")
        self.BadBirth.apply_value("BIRT", parse_date("1 JAN 2525"))
        
        self.BadDeath = Individual("@death@")
        self.BadDeath.apply_value("BIRT", parse_date("1 JUN 1945"))
        self.BadDeath.apply_value("DEAT", parse_date("1 JAN 4545"))
        
        self.OkayFam = Family("@okayf@")
        self.OkayFam.apply_value("MARR", parse_date("15 SEP 1960"))
        self.OkayFam.apply_value("DIV", parse_date("15 SEP 1970"))
        
        self.BadMarr = Family("@badmarr@")
        self.BadMarr.apply_value("MARR", parse_date("15 SEP 2960"))
        
        self.BadDiv = Family("@baddiv@")
        self.BadDiv.apply_value("DIV", parse_date("15 SEP 2970"))
        
        self.DoubleBadIndi = Individual("@doubleIndi@")
        self.DoubleBadIndi.apply_value("BIRT", parse_date("1 JUN 3945"))
        self.DoubleBadIndi.apply_value("DEAT", parse_date("1 JAN 4545"))
        
        self.DoubleBadFam = Family("@doubleFam@")
        self.DoubleBadFam.apply_value("MARR", parse_date("15 SEP 2960"))
        self.DoubleBadFam.apply_value("DIV", parse_date("15 SEP 2970"))
    
    def test_birth(self):
        """Test warnings for future births."""
        warnings = self.BadBirth._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  1)
        self.assertTrue('@birth@' in warnings[0].message and "birth date" in warnings[0].message)

    def test_death(self):
        """Test warnings for future deaths."""
        warnings = self.BadDeath._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  1)
        self.assertTrue('@death@' in warnings[0].message and "death date" in warnings[0].message)
        
    def test_okay_individual(self):
        """Test no warning case."""
        warnings = self.OkayIndi._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  0)
    
    def test_marriage(self):
        """Test warnings for future marriages."""
        warnings = self.BadMarr._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  1)
        self.assertTrue('@badmarr@' in warnings[0].message and "marriage date" in warnings[0].message)

    def test_divorce(self):
        """Test warnings for future divorces."""
        warnings = self.BadDiv._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  1)
        self.assertTrue('@baddiv@' in warnings[0].message and "divorce date" in warnings[0].message)

    def test_double_warnings(self):
        """Test warnings for multiple issues."""
        warnings = self.DoubleBadFam._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  2)
        
        warnings = self.DoubleBadIndi._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  2)   
        
    def test_okay_family(self):
        """Test no warning case."""
        warnings = self.OkayFam._Check_Dates_Before_Today()
        self.assertEqual(len(warnings),  0)
        
    def test_full_path(self):
        """Integration test for full parser->objects->validation data path."""
        buff = StringIO("""0 @I1@ INDI
1 NAME CrankyFrank /Coffin/
1 SEX M
1 BIRT
2 DATE 2 JAN 2940
1 FAMS @F1@
0 @I2@ INDI
1 NAME MarvelousMay /Coffin/
1 SEX F
1 BIRT
2 DATE 15 MAY 2941
1 FAMS @F1@
0 @F1@ FAM
1 HUSB @I1@
1 WIFE @I2@
1 MARR
2 DATE 15 JUL 2972
1 DIV
2 DATE 15 JUL 2973""")
        (ind,  fam,  unused_warns) = parse_file(buff)
        warnings = collect_validation_warnings(ind,  fam)
        count_of_us01_errors = 0
        for warn in warnings:
            if warn.story == "US01": count_of_us01_errors += 1
        self.assertEqual(count_of_us01_errors,  4)
コード例 #30
0
def Empty_Record(tag, id):
    """Helper function for making an empty record based on GEDCOM tag."""
    if tag == "INDI":
        return Individual(identifier=id)
    else:
        return Family(identifier=id)