class OutputTest(unittest.TestCase): def setUp(self): self.indi = Individual() self.indi.addID('@I2@') self.indi.addName('John Rivas') self.indi.addSex('M') self.indi.addBirt('9 MAY 1978') self.indi.addDeat('12 APR 2013') self.indi.addFams('@F2@') self.indi.addFamc('@F1@') self.fam1 = Family() self.fam1.addFamID('@F2@') self.fam1.addHusb('@I2@') self.fam1.addWife('@I2@') self.fam1.addChil('@I2@') self.fam1.addChil('@I2@') self.individuals = dict() self.individuals["one"] = self.indi self.families = dict() self.families["one"] = self.fam1 def test_outputIndiSummary(self): outputIndiSummary(self.individuals) def test_outputFamSummary(self): outputFamSummary(self.families, self.individuals)
class IndividualTest(unittest.TestCase): def setUp(self): self.indi = Individual() self.indi.addID('@I2@') self.indi.addName('John Rivas') self.indi.addSex('M') self.indi.addBirt('9 MAY 1978') self.indi.addDeat('12 APR 2013') self.indi.addFams('@F2@') self.indi.addFamc('@F1@') """ Test setters """ def test_addID(self): indi = Individual() value = '@A1@' indi.addID(value) self.assertEqual(indi.getID(), value) def test_addName(self): indi = Individual() value = "Gloop" indi.addName(value) self.assertEqual(indi.getName(), value) def test_addSex(self): indi = Individual() value = "M" indi.addSex(value) self.assertEqual(indi.getSex(), value) value = "F" indi.addSex(value) self.assertEqual(indi.getSex(), value) def test_addBirt(self): indi = Individual() value = "01 JAN 1900" indi.addBirt(value) self.assertEqual(indi.getBirt(), value) def test_addDeat(self): indi = Individual() value = "01 JAN 2000" indi.addDeat(value) self.assertEqual(indi.getDeat(), value) def test_addFams(self): indi = Individual() value = '@A1@' indi.addFams(value) self.assertEqual(indi.getFams()[0], value) def test_addFamc(self): indi = Individual() value = '@A1@' indi.addFamc(value) self.assertEqual(indi.getFamc()[0], value) """ Test getters """ def test_getID(self): ID = '@I2@' self.assertEqual(self.indi.getID(), ID) indi = Individual() self.assertEqual(indi.getID(), None) def test_getName(self): NAME = 'John Rivas' self.assertEqual(self.indi.getName(), NAME) indi = Individual() self.assertEqual(indi.getName(), None) def test_getSex(self): SEX = 'M' self.assertEqual(self.indi.getSex(), SEX) indi = Individual() self.assertEqual(indi.getSex(), None) def test_getBirt(self): BIRT = '9 MAY 1978' self.assertEqual(self.indi.getBirt(), BIRT) indi = Individual() self.assertEqual(indi.getBirt(), None) def test_getDeat(self): DEAT = '12 APR 2013' self.assertEqual(self.indi.getDeat(), DEAT) indi = Individual() self.assertEqual(indi.getDeat(), None) def test_getFams(self): FAMS = ['@F2@'] self.assertEqual(self.indi.getFams(), FAMS) indi = Individual() self.assertEqual(indi.getFams(), []) def test_getFamc(self): FAMC = ['@F1@'] self.assertEqual(self.indi.getFamc(), FAMC) indi = Individual() self.assertEqual(indi.getFamc(), [])
def test_addBirt(self): indi = Individual() value = "01 JAN 1900" indi.addBirt(value) self.assertEqual(indi.getBirt(), value)
class GedcomTest(unittest.TestCase): def setUp(self): self.indi1 = Individual() self.indi1.addID('@I1@') self.indi1.addName('John Rivas') self.indi1.addSex('M') self.indi1.addBirt('9 MAY 1978') self.indi1.addDeat('12 APR 2013') self.indi2 = Individual() self.indi2.addID('@I2@') self.indi2.addName('Mary Rivas') self.indi2.addSex('F') self.indi2.addBirt('21 APR 1980') self.indi2.addDeat('12 SEP 1990') self.indi3 = Individual() self.indi3.addID('@I3@') self.indi3.addName('Mary Rivas') self.indi3.addSex('F') self.indi3.addBirt('21 APR 1980') self.indi3.addDeat('12 SEP 2014') self.indi4 = Individual() self.indi4.addID('@I4@') self.indi4.addName('Mike Rivas') self.indi4.addSex('M') self.indi4.addBirt('21 APR 1976') self.indi5 = Individual() self.indi5.addID('@I5@') self.indi5.addName('Mike Rivas') self.indi5.addSex('M') self.indi5.addBirt('21 APR 2012') self.indi6 = Individual() self.indi6.addID('@I6@') self.indi6.addName('Mike Rivas') self.indi6.addSex('M') self.indi6.addBirt('21 APR 1988') self.indi6.addFamc('@F8@') self.indi7 = Individual() self.indi7.addID('@I7@') self.indi7.addName('Laura Rivas') self.indi7.addSex('F') self.indi7.addBirt('21 APR 1990') self.indi7.addFamc('@F8@') self.indi8 = Individual() self.indi8.addID('@I8@') self.indi8.addName('Laura Rivas') self.indi8.addSex('F') self.indi8.addBirt('21 APR 1990') self.indi8.addFamc('@F9@') self.individuals = dict() self.individuals['1'] = self.indi1 self.individuals['2'] = self.indi2 self.individuals['3'] = self.indi3 self.individuals['4'] = self.indi4 self.individuals['5'] = self.indi5 self.individuals['6'] = self.indi6 self.individuals['7'] = self.indi7 self.individuals['8'] = self.indi8 self.fam1 = Family() self.fam1.addFamID('@F2@') self.fam1.addHusb('@I1@') self.fam1.addWife('@I2@') self.fam1.addChil('@I4@') self.fam1.addChil('@I5@') self.fam1.addMarr('5 OCT 1999') self.fam1.addDiv('12 JUN 2012') self.fam2 = Family() self.fam2.addFamID('@F3@') self.fam2.addHusb('@I3@') self.fam2.addWife('@I3@') self.fam3 = Family() self.fam3.addFamID('@F3@') self.fam3.addHusb('@I1@') self.fam3.addWife('@I2@') self.fam3.addChil('@I4@') self.fam3.addChil('@I5@') self.fam3.addMarr('5 OCT 1999') self.fam3.addDiv('12 JUN 2012') self.fam4 = Family() self.fam4.addFamID('@F4@') self.fam4.addHusb('@I1@') self.fam4.addWife('@I3@') self.fam4.addChil('@I4@') self.fam4.addMarr('5 OCT 1999') self.fam4.addDiv('12 JUN 2012') self.fam5 = Family() self.fam5.addFamID('@F5@') self.fam5.addHusb('@I1@') self.fam5.addWife('@I3@') self.fam5.addChil('@I5@') self.fam5.addMarr('5 OCT 1999') self.fam5.addDiv('12 JUN 2012') def test_checkSameHusbWife(self): self.assertTrue(checkSameHusbWife(self.fam2)) self.assertFalse(checkSameHusbWife(self.fam1)) def test_checkDeathBeforeBirth(self): self.indi1.addBirt('9 MAY 1978') self.indi1.addDeat('9 MAY 1913') self.assertTrue(checkDeathBeforeBirth(self.indi1)) self.indi1.addDeat('9 MAY 1978') self.assertFalse(checkDeathBeforeBirth(self.indi1)) self.indi1.addDeat('12 APR 2013') self.assertFalse(checkDeathBeforeBirth(self.indi1)) self.indi1.addDeat(None) self.assertFalse(checkDeathBeforeBirth(self.indi1)) def test_checkMarryDead(self): self.assertTrue(checkMarryDead(self.fam3, self.individuals)) self.assertFalse(checkMarryDead(self.fam4, self.individuals)) def test_checkChildBeforeParents(self): self.assertTrue(checkChildBeforeParents(self.fam4, self.individuals)) self.assertFalse(checkChildBeforeParents(self.fam5, self.individuals)) def test_checkWifeIsMale(self): self.fam1.addWife('@I1@') self.assertTrue(checkWifeIsMale(self.fam1, self.individuals)) self.fam1.addWife('@I2@') self.assertFalse(checkWifeIsMale(self.fam1, self.individuals)) def test_checkHusbandIsFemale(self): self.fam1.addHusb('@I2@') self.assertTrue(checkHusbandIsFemale(self.fam1, self.individuals)) self.fam1.addHusb('@Ii@') self.assertFalse(checkHusbandIsFemale(self.fam1, self.individuals)) def test_marriedBeforeBirth(self): self.indi1.addBirt('9 MAY 1915') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1914') self.assertTrue(marriedBeforeBirth(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1800') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1994') self.assertFalse(marriedBeforeBirth(self.fam1, self.individuals)) def test_marriedTooYoung(self): self.indi1.addBirt('9 MAY 1900') self.indi2.addBirt('21 APR 1900') self.fam1.addMarr('9 MAY 1912') self.assertTrue(marriedTooYoung(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1800') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1994') self.assertFalse(marriedTooYoung(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1800') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1600') self.assertFalse(marriedTooYoung(self.fam1, self.individuals)) def test_deathBeforeMarriage(self): self.indi1.addDeat('9 MAY 2013') self.indi2.addDeat('12 SEP 1990') self.fam1.addMarr('9 MAY 2014') self.assertTrue(deathBeforeMarriage(self.fam1, self.individuals)) self.indi1.addDeat('9 MAY 1800') self.indi2.addDeat('12 SEP 1990') self.fam1.addMarr('9 MAY 1800') self.assertFalse(deathBeforeMarriage(self.fam1, self.individuals)) self.indi1.addDeat('9 MAY 2015') self.indi2.addDeat('12 SEP 1990') self.fam1.addMarr('9 MAY 1800') self.assertFalse(deathBeforeMarriage(self.fam1, self.individuals)) self.assertTrue(checkMarryDead(self.fam3, self.individuals)) self.assertFalse(checkMarryDead(self.fam4, self.individuals)) def test_divorceBeforeMarriage(self): self.fam1.addMarr('9 MAY 1914') self.fam1.addDiv('9 MAY 1900') self.assertTrue(divorceBeforeMarriage(self.fam1, self.individuals)) self.fam1.addMarr('9 MAY 1914') self.fam1.addDiv('9 MAY 1925') self.assertFalse(divorceBeforeMarriage(self.fam1, self.individuals)) self.assertFalse(divorceBeforeMarriage(self.fam2, self.individuals)) def test_tooManyChildren(self): self.assertFalse(tooManyChildren(self.fam1)) famT = Family() self.assertFalse(tooManyChildren(famT)) famT.addChil("1") famT.addChil("2") famT.addChil("3") famT.addChil("4") famT.addChil("5") self.assertTrue(tooManyChildren(famT)) def test_tooOldParent(self): self.assertFalse(tooOldParent(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1578') self.assertTrue(tooOldParent(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1978') self.indi4.addBirt('21 APR 2076') self.assertTrue(tooOldParent(self.fam1, self.individuals)) def test_marriedMoreThanOnePerson(self): self.families = dict() self.famA = Family() self.famA.addFamID('@A1@') self.famA.addHusb('@H1@') self.famA.addWife('@W1@') self.families['1'] = self.famA self.assertFalse(marriedMoreThanOnePerson(self.families)) self.famB = Family() self.famB.addFamID('@B1@') self.famB.addHusb('@H2@') self.famB.addWife('@W2@') self.families['2'] = self.famB self.assertFalse(marriedMoreThanOnePerson(self.families)) self.famB.addWife('@W1@') self.assertTrue(marriedMoreThanOnePerson(self.families)) self.famA.addDiv('12 JUN 2012') self.famB.addWife('@W1@') self.assertFalse(marriedMoreThanOnePerson(self.families)) def test_marriedToSiblings(self): self.famA = Family() self.famA.addFamID('@F6@') self.famA.addHusb('@I6@') self.famA.addWife('@I7@') self.famA.addMarr('5 OCT 1999') self.assertTrue(marriedToSiblings(self.famA, self.individuals)) self.famB = Family() self.famB.addFamID('@F6@') self.famB.addHusb('@I6@') self.famB.addWife('@I8@') self.famB.addMarr('5 OCT 1999') self.assertFalse(marriedToSiblings(self.famB, self.individuals))
class GedcomTest(unittest.TestCase): def setUp(self): self.indi1 = Individual() self.indi1.addID('@I1@') self.indi1.addName('John Rivas') self.indi1.addSex('M') self.indi1.addBirt('9 MAY 1978') self.indi1.addDeat('12 APR 2013') self.indi2 = Individual() self.indi2.addID('@I2@') self.indi2.addName('Mary Rivas') self.indi2.addSex('F') self.indi2.addBirt('21 APR 1980') self.indi2.addDeat('12 SEP 1990') self.indi3 = Individual() self.indi3.addID('@I3@') self.indi3.addName('Mary Rivas') self.indi3.addSex('F') self.indi3.addBirt('21 APR 1980') self.indi3.addDeat('12 SEP 2014') self.indi4 = Individual() self.indi4.addID('@I4@') self.indi4.addName('Mike Rivas') self.indi4.addSex('M') self.indi4.addBirt('21 APR 1976') self.indi5 = Individual() self.indi5.addID('@I5@') self.indi5.addName('Mike Rivas') self.indi5.addSex('M') self.indi5.addBirt('21 APR 2012') self.individuals = dict() self.individuals['1'] = self.indi1 self.individuals['2'] = self.indi2 self.individuals['3'] = self.indi3 self.individuals['4'] = self.indi4 self.individuals['5'] = self.indi5 self.fam1 = Family() self.fam1.addFamID('@F2@') self.fam1.addHusb('@I1@') self.fam1.addWife('@I2@') self.fam1.addChil('@I4@') self.fam1.addChil('@I5@') self.fam1.addMarr('5 OCT 1999') self.fam1.addDiv('12 JUN 2012') self.fam2 = Family() self.fam2.addFamID('@F3@') self.fam2.addHusb('@I3@') self.fam2.addWife('@I3@') self.fam3 = Family() self.fam3.addFamID('@F3@') self.fam3.addHusb('@I1@') self.fam3.addWife('@I2@') self.fam3.addChil('@I4@') self.fam3.addChil('@I5@') self.fam3.addMarr('5 OCT 1999') self.fam3.addDiv('12 JUN 2012') self.fam4 = Family() self.fam4.addFamID('@F4@') self.fam4.addHusb('@I1@') self.fam4.addWife('@I3@') self.fam4.addChil('@I4@') self.fam4.addMarr('5 OCT 1999') self.fam4.addDiv('12 JUN 2012') self.fam5 = Family() self.fam5.addFamID('@F5@') self.fam5.addHusb('@I1@') self.fam5.addWife('@I3@') self.fam5.addChil('@I5@') self.fam5.addMarr('5 OCT 1999') self.fam5.addDiv('12 JUN 2012') def test_checkSameHusbWife(self): self.assertTrue(checkSameHusbWife(self.fam2)) self.assertFalse(checkSameHusbWife(self.fam1)) def test_checkDeathBeforeBirth(self): self.indi1.addBirt('9 MAY 1978') self.indi1.addDeat('9 MAY 1913') self.assertTrue(checkDeathBeforeBirth(self.indi1)) self.indi1.addDeat('9 MAY 1978') self.assertFalse(checkDeathBeforeBirth(self.indi1)) self.indi1.addDeat('12 APR 2013') self.assertFalse(checkDeathBeforeBirth(self.indi1)) self.indi1.addDeat(None) self.assertFalse(checkDeathBeforeBirth(self.indi1)) def test_checkMarryDead(self): self.assertTrue(checkMarryDead(self.fam3, self.individuals)) self.assertFalse(checkMarryDead(self.fam4, self.individuals)) def test_checkChildBeforeParents(self): self.assertTrue(checkChildBeforeParents(self.fam4, self.individuals)) self.assertFalse(checkChildBeforeParents(self.fam5, self.individuals)) def test_checkWifeIsMale(self): self.fam1.addWife('@I1@') self.assertTrue(checkWifeIsMale(self.fam1, self.individuals)) self.fam1.addWife('@I2@') self.assertFalse(checkWifeIsMale(self.fam1, self.individuals)) def test_checkHusbandIsFemale(self): self.fam1.addHusb('@I2@') self.assertTrue(checkHusbandIsFemale(self.fam1, self.individuals)) self.fam1.addHusb('@Ii@') self.assertFalse(checkHusbandIsFemale(self.fam1, self.individuals)) def test_marriedBeforeBirth(self): self.indi1.addBirt('9 MAY 1915') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1914') self.assertTrue(marriedBeforeBirth(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1800') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1994') self.assertFalse(marriedBeforeBirth(self.fam1, self.individuals)) def test_marriedTooYoung(self): self.indi1.addBirt('9 MAY 1900') self.indi2.addBirt('21 APR 1900') self.fam1.addMarr('9 MAY 1912') self.assertTrue(marriedTooYoung(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1800') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1994') self.assertFalse(marriedTooYoung(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1800') self.indi2.addBirt('21 APR 1980') self.fam1.addMarr('9 MAY 1600') self.assertFalse(marriedTooYoung(self.fam1, self.individuals)) def test_deathBeforeMarriage(self): self.indi1.addDeat('9 MAY 2013') self.indi2.addDeat('12 SEP 1990') self.fam1.addMarr('9 MAY 2014') self.assertTrue(deathBeforeMarriage(self.fam1, self.individuals)) self.indi1.addDeat('9 MAY 1800') self.indi2.addDeat('12 SEP 1990') self.fam1.addMarr('9 MAY 1800') self.assertFalse(deathBeforeMarriage(self.fam1, self.individuals)) self.indi1.addDeat('9 MAY 2015') self.indi2.addDeat('12 SEP 1990') self.fam1.addMarr('9 MAY 1800') self.assertFalse(deathBeforeMarriage(self.fam1, self.individuals)) self.assertTrue(checkMarryDead(self.fam3, self.individuals)) self.assertFalse(checkMarryDead(self.fam4, self.individuals)) def test_divorceBeforeMarriage(self): self.fam1.addMarr('9 MAY 1914') self.fam1.addDiv('9 MAY 1900') self.assertTrue(divorceBeforeMarriage(self.fam1, self.individuals)) self.fam1.addMarr('9 MAY 1914') self.fam1.addDiv('9 MAY 1925') self.assertFalse(divorceBeforeMarriage(self.fam1, self.individuals)) self.assertFalse(divorceBeforeMarriage(self.fam2, self.individuals)) def test_tooManyChildren(self): self.assertFalse(tooManyChildren(self.fam1)) famT = Family() self.assertFalse(tooManyChildren(famT)) famT.addChil("1") famT.addChil("2") famT.addChil("3") famT.addChil("4") famT.addChil("5") self.assertTrue(tooManyChildren(famT)) def test_tooOldParent(self): self.assertFalse(tooOldParent(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1578') self.assertTrue(tooOldParent(self.fam1, self.individuals)) self.indi1.addBirt('9 MAY 1978') self.indi4.addBirt('21 APR 2076') self.assertTrue(tooOldParent(self.fam1, self.individuals)) def test_marriedMoreThanOnePerson(self): self.families = dict() self.famA = Family() self.famA.addFamID('@A1@') self.famA.addHusb('@H1@') self.famA.addWife('@W1@') self.families['1'] = self.famA self.assertFalse(marriedMoreThanOnePerson(self.families)) self.famB = Family() self.famB.addFamID('@B1@') self.famB.addHusb('@H2@') self.famB.addWife('@W2@') self.families['2'] = self.famB self.assertFalse(marriedMoreThanOnePerson(self.families)) self.famB.addWife('@W1@') self.assertTrue(marriedMoreThanOnePerson(self.families)) self.famA.addDiv('12 JUN 2012') self.famB.addWife('@W1@') self.assertFalse(marriedMoreThanOnePerson(self.families))