예제 #1
0
    def testTitle(self):
        gedcomfile = gedcom.parse_string(
            "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 TITL King\n0 TRLR"
        )
        self.assertEqual(list(gedcomfile.individuals)[0].title, 'King')

        gedcomfile = gedcom.parse_string(
            "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n0 TRLR")
        self.assertEqual(list(gedcomfile.individuals)[0].title, None)
예제 #2
0
 def testIdAssismentIsRobust(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n\n0 TRLR")
     element1 = gedcom.Individual()
     self.assertEqual(element1.id, None)
     gedcomfile.add_element(element1)
     self.assertEqual(element1.id, '@I2@')
예제 #3
0
 def testDeath(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 DEAT\n2 DATE 1980\n2 PLAC London\n0 TRLR"
     )
     ind = list(gedcomfile.individuals)[0]
     death = ind.death
     self.assertEqual(death.place, "London")
     self.assertEqual(death.date, "1980")
예제 #4
0
파일: tests.py 프로젝트: rory/gedcompy
    def testFamilies(self):
        gedcomfile = gedcom.parse_string(GEDCOM_FILE)
        fam = list(gedcomfile.families)[0]

        self.assertEqual(len(fam.husbands), 1)
        husband = fam.husbands[0].as_individual()
        self.assertEqual(husband.name, ('Robert', 'Cox'))
        self.assertEqual(husband.id, '@I1@')

        self.assertEqual(len(fam.wives), 1)
        wives = fam.wives[0].as_individual()
        self.assertEqual(wives.name, ('Joann', 'Para'))
        self.assertEqual(wives.id, '@I2@')
예제 #5
0
    def testFamilies(self):
        gedcomfile = gedcom.parse_string(GEDCOM_FILE)
        fam = list(gedcomfile.families)[0]

        self.assertEqual(len(fam.husbands), 1)
        husband = fam.husbands[0].as_individual()
        self.assertEqual(husband.name, ('Robert', 'Cox'))
        self.assertEqual(husband.id, '@I1@')

        self.assertEqual(len(fam.wives), 1)
        wives = fam.wives[0].as_individual()
        self.assertEqual(wives.name, ('Joann', 'Para'))
        self.assertEqual(wives.id, '@I2@')
예제 #6
0
    def testSaveFile(self):
        gedcomfile = gedcom.parse_string(GEDCOM_FILE)
        outputfile = tempfile.NamedTemporaryFile()
        outputfilename = outputfile.name
        gedcomfile.save(outputfile)
        outputfile.seek(0, 0)

        self.assertEqual(outputfile.read(), GEDCOM_FILE.encode("utf8"))
        self.assertRaises(Exception, gedcomfile.save, (outputfilename))
        outputfile.close()

        gedcomfile.save(outputfilename)
        with open(outputfilename) as output:
            self.assertEqual(output.read(), GEDCOM_FILE)
        remove(outputfilename)
예제 #7
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testSaveFile(self):
     gedcomfile = gedcom.parse_string(GEDCOM_FILE)
     outputfile = tempfile.NamedTemporaryFile()
     outputfilename = outputfile.name
     gedcomfile.save(outputfile)
     outputfile.seek(0,0)
     
     self.assertEqual(outputfile.read(), GEDCOM_FILE.encode("utf8"))
     self.assertRaises(Exception, gedcomfile.save, (outputfilename))
     outputfile.close()
     
     gedcomfile.save(outputfilename)
     with open(outputfilename) as output:
         self.assertEqual(output.read(), GEDCOM_FILE)
     remove(outputfilename)
예제 #8
0
    def testCanParse(self):
        parsed = gedcom.parse_string(GEDCOM_FILE)
        self.assertTrue(isinstance(parsed, gedcom.GedcomFile))

        people = list(parsed.individuals)
        self.assertTrue(len(people), 3)

        bob = people[0]
        self.assertEqual(bob.name, ("Robert", "Cox"))
        self.assertEqual(bob.aka, [("Bob", "Cox"), ('Rob', 'Cox')])
        self.assertEqual(bob.sex, 'M')
        self.assertEqual(bob.gender, 'M')
        self.assertTrue(bob.is_male)
        self.assertFalse(bob.is_female)
        self.assertEqual(bob.parents, [])
        self.assertEqual(bob.father, None)
        self.assertEqual(bob.mother, None)

        joann = people[1]
        self.assertEqual(joann.name, ("Joann", "Para"))
        self.assertEqual(joann.sex, 'F')
        self.assertEqual(joann.gender, 'F')
        self.assertFalse(joann.is_male)
        self.assertTrue(joann.is_female)
        self.assertEqual(joann.parents, [])

        bobby_jo = people[2]
        self.assertEqual(bobby_jo.name, ("Bobby Jo", "Cox"))
        self.assertEqual(bobby_jo.sex, 'M')
        self.assertEqual(bobby_jo.gender, 'M')
        self.assertTrue(bobby_jo.is_male)
        self.assertFalse(bobby_jo.is_female)
        self.assertEqual(bobby_jo.parents, [bob, joann])
        self.assertEqual(bobby_jo.father, bob)
        self.assertEqual(bobby_jo.mother, joann)

        families = list(parsed.families)
        self.assertEqual(len(families), 1)
        family = families[0]
        self.assertEqual(family.__class__, gedcom.Family)
        self.assertEqual([p.as_individual() for p in family.partners],
                         [bob, joann])
예제 #9
0
파일: tests.py 프로젝트: BioGeek/gedcompy
    def testCanParse(self):
        parsed = gedcom.parse_string(GEDCOM_FILE)
        self.assertTrue(isinstance(parsed, gedcom.GedcomFile))

        people = list(parsed.individuals)
        self.assertTrue(len(people), 3)

        bob = people[0]
        self.assertEquals(bob.name, ("Robert", "Cox"))
        self.assertEquals(bob.aka, [("Bob", "Cox"), ('Rob', 'Cox')])
        self.assertEquals(bob.sex, 'M')
        self.assertEquals(bob.gender, 'M')
        self.assertTrue(bob.is_male)
        self.assertFalse(bob.is_female)
        self.assertEquals(bob.parents, [])
        self.assertEquals(bob.father, None)
        self.assertEquals(bob.mother, None)

        joann = people[1]
        self.assertEquals(joann.name, ("Joann", "Para"))
        self.assertEquals(joann.sex, 'F')
        self.assertEquals(joann.gender, 'F')
        self.assertFalse(joann.is_male)
        self.assertTrue(joann.is_female)
        self.assertEquals(joann.parents, [])

        bobby_jo = people[2]
        self.assertEquals(bobby_jo.name, ("Bobby Jo", "Cox"))
        self.assertEquals(bobby_jo.sex, 'M')
        self.assertEquals(bobby_jo.gender, 'M')
        self.assertTrue(bobby_jo.is_male)
        self.assertFalse(bobby_jo.is_female)
        self.assertEquals(bobby_jo.parents, [bob, joann])
        self.assertEquals(bobby_jo.father, bob)
        self.assertEquals(bobby_jo.mother, joann)

        families = list(parsed.families)
        self.assertEquals(len(families), 1)
        family = families[0]
        self.assertEquals(family.__class__, gedcom.Family)
        self.assertEquals([p.as_individual() for p in family.partners], [bob, joann])
예제 #10
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testNoteConc(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 NOTE foo\n2 CONC bar\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].note, 'foobar')
예제 #11
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testSupportNameInOneWithSlashes(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME Bob /Cox/\n\n0 TRLR")
     self.assertEqual(gedcomfile['@I1@'].name, ('Bob', 'Cox'))
예제 #12
0
파일: tests.py 프로젝트: tropology/gedcompy
 def testDashInID(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1-123@ INDI\n1 NAME\n2 GIVN Bob\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, ('Bob', None))
예제 #13
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testIdAssismentIsRobust(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n\n0 TRLR")
     element1 = gedcom.Individual()
     self.assertEqual(element1.id, None)
     gedcomfile.add_element(element1)
     self.assertEqual(element1.id, '@I2@')
예제 #14
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testSupportNameInGivenAndSurname(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n\n0 TRLR")
     self.assertEqual(gedcomfile['@I1@'].name, ('Bob', 'Cox'))
예제 #15
0
 def testDashInID(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1-123@ INDI\n1 NAME\n2 GIVN Bob\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, ('Bob', None))
예제 #16
0
 def testSupportNameInGivenAndSurname(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n\n0 TRLR")
     self.assertEqual(gedcomfile['@I1@'].name, ('Bob', 'Cox'))
예제 #17
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testInvalidNames(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME Bob /Russel\n0 TRLR")
     self.assertRaises(Exception, lambda : list(gedcomfile.individuals)[0].name)
예제 #18
0
 def testSupportNameInOneWithSlashes(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME Bob /Cox/\n\n0 TRLR")
     self.assertEqual(gedcomfile['@I1@'].name, ('Bob', 'Cox'))
예제 #19
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testLastNameOnly1(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 SURN Bob\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, (None, 'Bob'))
예제 #20
0
파일: tests.py 프로젝트: BioGeek/gedcompy
    def testTitle(self):
        gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 TITL King\n0 TRLR")
        self.assertEqual(list(gedcomfile.individuals)[0].title, 'King')

        gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n0 TRLR")
        self.assertEqual(list(gedcomfile.individuals)[0].title, None)
예제 #21
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testNoteError(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 NOTE foo\n2 TITL bar\n0 TRLR")
     ind = list(gedcomfile.individuals)[0]
     self.assertRaises(ValueError, lambda : ind.note)
예제 #22
0
 def testNoteConc(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 NOTE foo\n2 CONC bar\n0 TRLR"
     )
     self.assertEqual(list(gedcomfile.individuals)[0].note, 'foobar')
예제 #23
0
 def testNoteError(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 NOTE foo\n2 TITL bar\n0 TRLR"
     )
     ind = list(gedcomfile.individuals)[0]
     self.assertRaises(ValueError, lambda: ind.note)
예제 #24
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testDeath(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME\n2 GIVN Bob\n2 SURN Cox\n1 DEAT\n2 DATE 1980\n2 PLAC London\n0 TRLR")
     ind = list(gedcomfile.individuals)[0]
     death = ind.death
     self.assertEquals(death.place, "London")
     self.assertEquals(death.date, "1980")
예제 #25
0
 def testFirstNameOnly2(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME Bob\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, ('Bob', None))
예제 #26
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testFirstNameOnly2(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME Bob\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, ('Bob', None))
예제 #27
0
 def testLastNameOnly1(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME\n2 SURN Bob\n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, (None, 'Bob'))
예제 #28
0
파일: tests.py 프로젝트: BioGeek/gedcompy
 def testEmptyName(self):
     gedcomfile = gedcom.parse_string("0 HEAD\n0 @I1@ INDI\n1 NAME \n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, (None, None))
예제 #29
0
 def testEmptyName(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME \n0 TRLR")
     self.assertEqual(list(gedcomfile.individuals)[0].name, (None, None))
예제 #30
0
 def testInvalidNames(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME Bob /Russel\n0 TRLR")
     self.assertRaises(Exception,
                       lambda: list(gedcomfile.individuals)[0].name)
예제 #31
0
 def testNameWithTooManySlashes(self):
     gedcomfile = gedcom.parse_string(
         "0 HEAD\n0 @I1@ INDI\n1 NAME Bob/Robert /Russel/\n\n0 TRLR")
     self.assertRaises(Exception,
                       lambda: list(gedcomfile.individuals)[0].name)