-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
82 lines (71 loc) · 3.33 KB
/
tests.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
import unittest
from modules import preprocess
class test_process_input(unittest.TestCase):
def test_functional_dependency_formatting(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input(
"inputs/test_inputs/functional_dependency_formatting_test.txt"
)
self.assertEqual(
str(context.exception),
"Invalid functional dependency format in relation CoffeeShopPromocodeUsedData. Format must be {attribute1, attribute2} -> {attribute1, attribute2}",
)
def test_multivalued_dependency_formatting(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input(
"inputs/test_inputs/multivalued_dependency_formatting_test.txt"
)
self.assertEqual(
str(context.exception),
"Invalid multivalued dependency format in relation CoffeeShopFoodAllergenData. Format must be {attribute1, attribute2} -->> {attribute1, attribute2}",
)
def test_foreign_key_formatting(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input(
"inputs/test_inputs/foreign_key_formatting_test.txt"
)
self.assertEqual(
str(context.exception),
"Invalid foreign key format in relation CoffeeShopPromocodeUsedData. Format must be {attribute1, attribute2} -> relation{attribute1, attribute2}",
)
def test_missing_braces(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input("inputs/test_inputs/missing_braces_test.txt")
self.assertEqual(
str(context.exception),
"Invalid syntax - Primary key must be formatted as {___, ___, ___} in relation CoffeeShopData",
)
def test_candidate_key_formatting(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input(
"inputs/test_inputs/candidate_key_formatting_test.txt"
)
self.assertEqual(
str(context.exception),
"Invalid syntax - Candidate keys must be formatted as {{___, ___}, {___, ___}} in relation CoffeeShopData",
)
def test_required_attrs(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input(
"inputs/test_inputs/missing_required_attr_test.txt"
)
self.assertEqual(
str(context.exception),
"Missing required field Primary key in relation CoffeeShopData",
)
def test_num_attrs(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input("inputs/test_inputs/num_attrs_test.txt")
self.assertEqual(
str(context.exception),
"The number of data types (4) must match the number of attributes (3) in relation CoffeeShopData",
)
def test_tuple_len(self):
with self.assertRaises(ValueError) as context:
preprocess.process_input("inputs/test_inputs/missing_tuple_attr_test.txt")
self.assertEqual(
str(context.exception),
"The number of values in tuple <['1002', 'SUMMERFUN']> (2) must match the number of attributes (3) in relation CoffeeShopData",
)
if __name__ == "__main__":
unittest.main()