Skip to content

Commit

Permalink
Added US21
Browse files Browse the repository at this point in the history
Correct gender roles for husband and wife
  • Loading branch information
kgensheimer committed Oct 28, 2018
1 parent 7be65b6 commit a29c90c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
21 changes: 19 additions & 2 deletions Bad_GEDCOM_test_data.ged
Original file line number Diff line number Diff line change
Expand Up @@ -470,17 +470,29 @@
0 @I75@ INDI
1 NAME Gorl /Sib/
1 SEX F
1 BIRT
1 BIRT
2 DATE 19 MAR 1985
1 FAMS @F26@
1 FAMC @F25@
0 @I76@ INDI
1 NAME Boyle /Sib/
1 SEX M
1 BIRT
1 BIRT
2 DATE 25 MAR 1986
1 FAMS @F26@
1 FAMC @F25@
0 @I77@ INDI
1 NAME James /Switcheroo/
1 SEX F
1 BIRT
2 DATE 23 FEB 1980
1 FAMS @F27@
0 @I78@ INDI
1 NAME Jenny /Switcheroo/
1 SEX M
1 BIRT
2 DATE 19 OCT 1982
1 FAMS @F27@
0 NOTE -----------------Start of the Families-------------------
0 @F1@ FAM
1 HUSB @I1@
Expand Down Expand Up @@ -674,3 +686,8 @@
1 WIFE @I75@
1 MARR
2 DATE 1 JAN 2005
0 @F27@ FAM
1 HUSB @I77@
1 WIFE @I78@
1 MARR
2 DATE 6 FEB 2004
16 changes: 14 additions & 2 deletions GedcomProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def __init__(self, ind_dict, fam_dict, errors, print_errors):
self.too_many_siblings() #US15
self.no_marriage_to_descendants()#US17
self.no_marriage_to_siblings() #US18
self.correct_gender_role() #US21
self.unique_names_and_bdays() #US23
self.unique_spouses_in_family() #US24
self.unique_children_in_family() #US25
Expand Down Expand Up @@ -414,7 +415,7 @@ def no_marriage_to_descendants(self):
for fam in person.fams:
for child in self.family[fam].chil:
self.descendants_help(person,self.individuals[child])

def no_marriage_to_siblings(self):
"""US18: Tests to ensure that individuals do not marry their siblings"""
for person in self.individuals.values():
Expand All @@ -427,7 +428,18 @@ def no_marriage_to_siblings(self):
self.all_errors +=["US18: {} cannot be married to their sibling {}".format(person.name, self.individuals[self.family[fam].husb].name)]
elif(tempWife in self.family[person.famc].chil and self.individuals[self.family[fam].wife] != person):
self.all_errors +=["US18: {} cannot be married to their sibling {}".format(person.name, self.individuals[self.family[fam].wife].name)]


def correct_gender_role(self):
"""US21: Husband in family should be male and wife in family should be female"""
for fam in self.family.values():
familyName = str(self.individuals[fam.husb].name).split()[-1].strip("/")
husband = self.individuals[fam.husb]
wife = self.individuals[fam.wife]
if husband.sex == "F":
self.all_errors += ["US21: The husband in the {} family, ({}), is a female!".format(familyName, husband.name)]
if wife.sex == "M":
self.all_errors += ["US21: The wife in the {} family, ({}), is a male!".format(familyName, wife.name)]


def unique_names_and_bdays(self):
"""US23: Tests to ensure there are no individuals with the same name and birthdate"""
Expand Down
14 changes: 12 additions & 2 deletions Unit_Test_Proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,24 @@ def test_no_marriage_to_descendents(self):
list_of_known_errors = ["US17: John /Leffe/ cannot be married to their descendant Ava /Leffe/"]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_no_marriage_to_siblings(self):
"""US18: Test: Makes sure no_marriage_to_siblings finds all individuals married to one of their siblings"""
list_of_known_errors = ["US18: Boyle /Sib/ cannot be married to their sibling Gorl /Sib/",
list_of_known_errors = ["US18: Boyle /Sib/ cannot be married to their sibling Gorl /Sib/",
"US18: Gorl /Sib/ cannot be married to their sibling Boyle /Sib/"]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_correct_gender_role(self):
"""US21: Tests to ensure husband in family should be male and wife in family should be female"""
list_of_known_errors = ["US21: The husband in the Par family, (Martha /Par/), is a female!",
"US21: The husband in the Switcheroo family, (James /Switcheroo/), is a female!",
"US21: The wife in the Johnson family, (Sammy /Johnson/), is a male!",
"US21: The wife in the Par family, (Far /Par/), is a male!",
"US21: The wife in the Switcheroo family, (Jenny /Switcheroo/), is a male!",]
for error in list_of_known_errors:
self.assertIn(error, self.all_errors)

def test_unique_ids(self):
"""US22: Tests to ensure that all IDS are unique"""
list_of_known_errors = ["US22: The individual ID: I52, already exists, this ID is not unique",
Expand Down

0 comments on commit a29c90c

Please sign in to comment.