diff --git a/seeds/test10.ged b/seeds/test10.ged new file mode 100644 index 0000000..7156df3 --- /dev/null +++ b/seeds/test10.ged @@ -0,0 +1,196 @@ +0 HEAD +1 SOUR Family Echo +2 WWW http://www.familyecho.com/ +1 FILE Family 2 +1 DATE 20 SEP 2020 +1 DEST ANSTFILE +1 GEDC +2 VERS 5.5.1 +2 FORM LINEAGE-LINKED +1 SUBM @I9@ +2 NAME Peter Damianov +1 SUBN +1 CHAR UTF-8 +0 @I1@ INDI +1 NAME John /Smith/ +2 GIVN John +2 SURN Smith +2 _MARNM Smith +1 SEX M +1 BIRT +2 DATE 11 AUG 1965 +1 FAMS @F1@ +1 FAMC @F2@ +0 @I2@ INDI +1 NAME Susan /Jones/ +2 GIVN Susan +2 SURN Jones +2 _MARNM Smith +1 SEX F +1 BIRT +2 DATE 14 AUG 1969 +1 FAMS @F1@ +1 FAMC @F3@ +0 @I3@ INDI +1 NAME Dylan /Smith/ +2 GIVN Dylan +2 SURN Smith +2 _MARNM Smith +1 SEX M +1 BIRT +2 DATE 21 NOV 2002 +1 FAMC @F1@ +0 @I4@ INDI +1 NAME Frank /Jones/ +2 GIVN Frank +2 SURN Jones +2 _MARNM Jones +1 SEX M +1 BIRT +2 DATE 9 APR 1940 +1 FAMS @F3@ +0 @I5@ INDI +1 NAME Emily /Michaels/ +2 GIVN Emily +2 SURN Michaels +2 _MARNM Jones +1 SEX F +1 BIRT +2 DATE 5 OCT 1942 +1 FAMS @F3@ +0 @I6@ INDI +1 NAME Bernard /Smith/ +2 GIVN Bernard +2 SURN Smith +2 _MARNM Smith +1 SEX M +1 BIRT +2 DATE 6 FEB 1940 +1 FAMS @F2@ +0 @I7@ INDI +1 NAME Theresa /Kelly/ +2 GIVN Theresa +2 SURN Kelly +2 _MARNM Smith +1 SEX F +1 BIRT +2 DATE 22 JUL 1941 +1 FAMS @F2@ +0 @I8@ INDI +1 NAME Kevin /Brown/ +2 GIVN Kevin +2 SURN Brown +2 _MARNM Jones +1 SEX M +1 BIRT +2 DATE 30 MAY 1967 +1 FAMS @F4@ +1 FAMS @F5@ +1 FAMC @F3@ +0 @I9@ INDI +1 NAME Diane /Brown/ +2 GIVN Diane +2 SURN Brown +2 _MARNM Jones +1 SEX F +1 BIRT +2 DATE 2 JAN 1970 +1 FAMS @F4@ +0 @I10@ INDI +1 NAME Paul /Smith/ +2 GIVN Paul +2 SURN Smith +2 _MARNM Smith +1 SEX M +1 BIRT +2 DATE 14 JUL 1968 +1 FAMC @F2@ +0 @I11@ INDI +1 NAME James /Jones/ +2 GIVN James +2 SURN Jones +2 _MARNM Jones +1 SEX M +1 BIRT +2 DATE 10 OCT 2007 +1 FAMC @F4@ +0 @I12@ INDI +1 NAME Lucia /Johnson/ +2 GIVN Lucia +2 SURN Johnson +2 _MARNM Jones +1 SEX F +1 BIRT +2 DATE 5 DEC 1967 +1 DEAT Y +2 DATE 11 MAY 2001 +1 FAMS @F5@ +0 @I13@ INDI +1 NAME Michelle /Jones/ +2 GIVN Michelle +2 SURN Jones +2 _MARNM Jones +1 SEX F +1 BIRT +2 DATE 8 MAR 1999 +1 FAMC @F5@ +0 @I14@ INDI +1 NAME Evan /Smith/ +2 GIVN Evan +2 SURN Smith +2 _MARNM Smith +1 SEX M +1 BIRT +2 DATE 10 NOV 1997 +1 FAMC @F1@ +0 @I15@ INDI +1 NAME Matthew /Smith/ +2 GIVN Matthew +2 SURN Smith +2 _MARNM Smith +1 SEX M +1 BIRT +2 DATE 1 JUL 1997 +1 FAMC @F1@ +0 @F1@ FAM +1 HUSB @I1@ +1 WIFE @I2@ +1 CHIL @I3@ +1 CHIL @I14@ +1 CHIL @I15@ +1 MARR +2 DATE 27 JUN 1995 +1 _CURRENT Y +0 @F2@ FAM +1 HUSB @I6@ +1 WIFE @I7@ +1 CHIL @I1@ +1 CHIL @I10@ +1 MARR +2 DATE 7 AUG 1965 +1 _CURRENT Y +0 @F3@ FAM +1 HUSB @I4@ +1 WIFE @I5@ +1 CHIL @I2@ +1 CHIL @I8@ +1 MARR +2 DATE 12 SEP 1965 +1 _CURRENT Y +0 @F4@ FAM +1 HUSB @I8@ +1 WIFE @I9@ +1 CHIL @I11@ +1 MARR +2 DATE 21 MAY 2006 +1 _CURRENT Y +0 @F5@ FAM +1 HUSB @I8@ +1 WIFE @I12@ +1 CHIL @I13@ +1 MARR +2 DATE 20 DEC 1996 +1 EVEN +2 TYPE Ending +1 _CURRENT N +0 TRLR diff --git a/src/UserStories/us13.py b/src/UserStories/us13.py new file mode 100644 index 0000000..9eec6c2 --- /dev/null +++ b/src/UserStories/us13.py @@ -0,0 +1,96 @@ +''' +Author: Samantha Inneo +Sprint: Sprint 1 +Use Case: Birth dates of siblings should be more than 8 months apart or less than 2 days apart + (twins may be born one day apart, e.g. 11:59 PM and 12:02 AM the following calendar day) +''' +import sys +sys.path.append("c:\\Users\\Stevens User\\555_Team_4\\Team-4-Code\\src") +import Project02 +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\seeds") +import pandas as pd +import datetime +import copy +import os +sys.path.append(os.path.abspath('../src/userstories')) + +def siblingsAgeGap(gedcom_name): + # I need to gather all the siblings of each family + # check if their birthdays are more than 8 months apart + # check if their birthdays are less than 2 days apart + #return true if they are valid, false if they are not + # eight_months = 240 + # two_days = 2 + + individuals = Project02.createIndividualsDataFrame(gedcom_name) + families = Project02.createFamiliesDataFrame(gedcom_name) + + child = [] + #indiv = copy.deepcopy(individuals[["Name", "Birthday", "Dead"]]) + + children = copy.deepcopy(families["Children"]) + #print(children) + #for index, row in children.iterrows(): + invalids = 0 + for row in families.Children: + if len(row) > 1: + for i in range(len(row)): + main = row[i] + row2 = [n for n in row if n != main] + + main_d = pd.to_datetime(list(individuals[individuals.ID == main].Birthday)[0]) + for x in row2: + x_d = pd.to_datetime(list(individuals[individuals.ID == x].Birthday)[0]) + if abs(int((main_d - x_d).days)) > 2 and abs(int((main_d - x_d).days)) < 240: + print("Individuals ", main, " and ", x, " are invalid.") + invalids+=1 + if invalids == 0: + print("All siblings are valid") + + + + +''' +import sys +import copy +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\src") +import Project02 +sys.path.append("C:\\Users\\Stevens User\\Documents\\GitHub\\Team-4-Code\\seeds") +import pandas as pd +import datetime + +def siblingsAgeGap(gedcom_name): + # I need to gather all the siblings of each family + # check if their birthdays are more than 8 months apart + # check if their birthdays are less than 2 days apart + #return true if they are valid, false if they are not + eight_months = 240 + two_days = 2 + + individuals = Project02.createIndividualsDataFrame(gedcom_name) + families = Project02.createFamiliesDataFrame(gedcom_name) + + child = [] + children = copy.deepcopy(families[["Children"]]) + indi = copy.deepcopy(individuals[["ID", "Birthday"]]) + for index, row in children.iterrows(): + #indiv = copy.deepcopy(individuals[["Name", "Birthday", "Dead"]]) + if len(row["Children"]) > 1: + for i in row["Children"]: + lst = row["Children"] + for j in lst: + for k, rows in indi.iterrows(): + if lst[j] == rows[individuals["ID"]]: + child.append(rows[individuals["Birthday"]]) + for m in range(len(child)): + child2 = child[:m] + child[m:] + for l in range(len(child2)): + if ((pd.to_datetime(child[k]) - pd.to_datetime(child2[l])) > two_days) and ((pd.to_datetime(child[k]) - pd.to_datetime(child[l])) < eight_months ): + print("invalid: sibling birthdays") + + +siblingsAgeGap("seeds/seed.ged") +''' + + + diff --git a/tests/us13_test.py b/tests/us13_test.py new file mode 100644 index 0000000..489f074 --- /dev/null +++ b/tests/us13_test.py @@ -0,0 +1,39 @@ +import unittest +import datetime +import sys +import os +sys.path.append(os.path.abspath('../src/userstories')) +import sys +# sys.path.append("c:\\Users\\Stevens User\\555_Team_4\\Team-4-Code\\seeds") +os.chdir("c:\\Users\\Stevens User\\555_Team_4\\Team-4-Code\\seeds") +from us13 import siblingsAgeGap + +class US_13_TEST(unittest.TestCase): + def test1(self): + filename = "seed.ged" + ret = "All siblings are valid" + self.assertEqual(siblingsAgeGap(filename),ret) + + def test2(self): + filename = "test1.ged" + ret = "All siblings are valid" + self.assertEqual(siblingsAgeGap(filename),ret) + + + def test3(self): + filename = "test2.ged" + ret = "All siblings are valid" + self.assertEqual(siblingsAgeGap(filename),ret) + + def test4(self): + filename = "test5.ged" + ret = "All siblings are valid" + self.assertEqual(siblingsAgeGap(filename),ret) + + def test5(self): + filename = "test4.ged" + ret = "Individuals I14 and I15 are invalid.\n Individuals I15 and I14 are invalid." + self.assertEqual(siblingsAgeGap(filename),ret) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/us30_test.py b/tests/us30_test.py new file mode 100644 index 0000000..0508b1b --- /dev/null +++ b/tests/us30_test.py @@ -0,0 +1,39 @@ +import unittest +import datetime +import sys +import os +sys.path.append(os.path.abspath('../src/userstories')) +import sys +# sys.path.append("c:\\Users\\Stevens User\\555_Team_4\\Team-4-Code\\seeds") +os.chdir("c:\\Users\\Stevens User\\555_Team_4\\Team-4-Code\\seeds") +from us30 import listLivingMarried + +class Inneo_Tests_HW4(unittest.TestCase): + def test1(self): + filename = "seed.ged" + ret = ['John Smith', 'Susan Jones', 'Frank Jones', 'Emily Michaels', 'Bernard Smith', 'Theresa Kelly', 'Kevin Brown', 'Diane Brown'] + self.assertEqual(listLivingMarried(filename),ret) + + def test2(self): + filename = "test1.ged" + ret = ['Sam Smith', 'Rick Smith', 'Hannah Smith', 'Alexa Smith'] + self.assertEqual(listLivingMarried(filename),ret) + + + def test3(self): + filename = "test2.ged" + ret = ['James Smith', 'Jen Smith', 'Claire Smith', 'Cody Smith', 'Rachel Smith', 'Rick Smith'] + self.assertEqual(listLivingMarried(filename),ret) + + def test4(self): + filename = "test3.ged" + ret = ['Sam Smith', 'Rick Smith', 'Hannah Smith'] + self.assertEqual(listLivingMarried(filename),ret) + + def test5(self): + filename = "test4.ged" + ret = ['Joseph Jones', 'Cassidy Smith', 'Betty Jefferson', 'Maria Hamilton'] + self.assertEqual(listLivingMarried(filename),ret) + +if __name__ == '__main__': + unittest.main()