-
Notifications
You must be signed in to change notification settings - Fork 0
/
unittests.py
138 lines (119 loc) · 5.66 KB
/
unittests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import unittest
import sys
from script import validDate, check_gender_roles, check_unique_child, isDateLegitimate, check_dupe_spouses, findTwins, findTriplets
from script import birthBeforeMarriage, reset, generateInitialData
class TestDates(unittest.TestCase):
def test_success(self):
result = validDate("15 OCT 2019")
self.assertTrue(result)
result = validDate("27 SEP 2020")
self.assertTrue(result)
def test_fail(self):
result = validDate("15 OCT 2021")
self.assertFalse(result)
result = validDate("28 SEP 2021")
self.assertFalse(result)
def test_input_fail(self):
with self.assertRaises(ValueError): validDate("15")
class TestBirthBeforeMarriage(unittest.TestCase):
def test_success(self):
print("Testing Birth Before Marriage Success")
reset()
gedcomStructuredData = generateInitialData("gedFiles/0BirthAfterDeath.ged") #store the tables and lists into gedcomStructuredData
famList_0warnings = gedcomStructuredData['famList']
result = birthBeforeMarriage(famList_0warnings)
self.assertTrue(result)
def test_fail(self):
print("Testing Birth Before Marriage Failure")
reset()
gedcomStructuredData = generateInitialData("gedFiles/2BirthAfterMarriage.ged") #store the tables and lists into gedcomStructuredData
famList_2warnings = gedcomStructuredData['famList']
result = birthBeforeMarriage(famList_2warnings)
self.assertFalse(result)
class TestGenderRoles(unittest.TestCase):
def test_success(self):
print("Testing Gender Roles Success")
reset()
gedcomStructuredData = generateInitialData("family_project.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_gender_roles(famList)
self.assertTrue(result)
def test_failure(self):
print("Testing Gender Roles Failure")
reset()
gedcomStructuredData = generateInitialData("gedFiles/WrongGenders.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_gender_roles(famList)
self.assertFalse(result)
class TestUniqueChild(unittest.TestCase):
def test_success(self):
print("Testing Unique Child Success")
reset()
gedcomStructuredData = generateInitialData("family_project.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_unique_child(famList)
self.assertTrue(result)
def test_failure(self):
print("Testing Unique Child Failure")
reset()
gedcomStructuredData = generateInitialData("gedFiles/NoUniqueChildren.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_unique_child(famList)
self.assertFalse(result)
class TestLegitDate(unittest.TestCase):
def test_success(self):
print("Testing Legit Date Success")
result = isDateLegitimate("8 NOV 2020")
self.assertTrue(result)
def test_failure(self):
print("Testing Legit Date Failure")
result = isDateLegitimate("31 NOV 2020")
self.assertFalse(result)
class TestDupeSpouses(unittest.TestCase):
def test_success(self):
print("Testing Dupe Spouses Success")
reset()
gedcomStructuredData = generateInitialData("family_project.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_dupe_spouses(famList)
self.assertTrue(result)
def test_failure(self):
print("Testing Dupe Spouses Failure")
reset()
gedcomStructuredData = generateInitialData("gedFiles/dupeSpouses.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_dupe_spouses(famList)
self.assertFalse(result)
class TestFindTwins(unittest.TestCase):
def test_empty(self):
print("Testing Find Twins Empty")
reset()
gedcomStructuredData = generateInitialData("family_project.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = findTwins(famList)
self.assertEqual(result, [])
def test_twins(self):
print("Testing Find Twins")
reset()
gedcomStructuredData = generateInitialData("gedFiles/twins.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = findTwins(famList)
self.assertEqual(result, [["I48", "I56"]])
class TestFindTriplets(unittest.TestCase):
def test_empty(self):
print("Testing Find Triplets Empty")
reset()
gedcomStructuredData = generateInitialData("family_project.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = findTriplets(famList)
self.assertEqual(result, [])
def test_triplets(self):
print("Testing Find Triplets")
reset()
gedcomStructuredData = generateInitialData("gedFiles/triplets.ged") #store the tables and lists into gedcomStructuredData
famList = gedcomStructuredData['famList']
result = check_unique_child(famList)
self.assertEqual(result, [["I48", "I56", "I64"]])
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromModule( sys.modules[__name__] )
unittest.TextTestRunner(verbosity=3).run( suite )