-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
147 lines (117 loc) · 5.22 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
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
139
140
141
142
143
144
145
146
147
import comparesv
def test_basic():
h1 = ["id", "age"]
h2 = ["id", "age"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [["A1", 23], ["A2", 24], ["A3", 34]]
result = [[True, True], [True, True], [True, True]]
values = [['[A1]:[A1]', '[23]:[23]'], ['[A2]:[A2]', '[24]:[24]'], ['[A3]:[A3]', '[34]:[34]']]
output = comparesv.run(d1, h1, d2, h2)
assert result == output['results']
assert values == output['values']
def test_basic_empty():
h1 = ["id", "age"]
h2 = ["id", "age"]
d1 = [["A1", 23], ["A2", 24], ["", 34]]
d2 = [["A1", 23], ["A2", 24], ["", 34]]
result = [[True, True], [True, True], [True, True]]
values = [['[A1]:[A1]', '[23]:[23]'], ['[A2]:[A2]', '[24]:[24]'], ['[]:[]', '[34]:[34]']]
output = comparesv.run(d1, h1, d2, h2)
assert result == output['results']
assert values == output['values']
def test_column_order():
h1 = ["id", "age"]
h2 = ["age", "id"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [[23, "A1"], [24, "A2"], [34, "A3"]]
result = [[True, True], [True, True], [True, True]]
values = [['[A1]:[A1]', '[23]:[23]'], ['[A2]:[A2]', '[24]:[24]'], ['[A3]:[A3]', '[34]:[34]']]
output = comparesv.run(d1, h1, d2, h2)
assert result == output['results']
assert values == output['values']
def test_fuzzy_column_order():
h1 = ["id", "age", "building age"]
h2 = ["age of student", "identity", "building age"]
d1 = [["A1", 23, 100], ["A2", 24, 100], ["A3", 34, 100]]
d2 = [[23, "A1", 100], [24, "A2", 100], [34, "A3", 100]]
result = [[True, True, True], [True, True, True], [True, True, True]]
values = [['[A1]:[A1]', '[23]:[23]','[100]:[100]'], ['[A2]:[A2]', '[24]:[24]','[100]:[100]'], ['[A3]:[A3]', '[34]:[34]','[100]:[100]']]
output = comparesv.run(d1, h1, d2, h2, column_match='fuzzy')
assert result == output['results']
assert values == output['values']
def test_row_order_fuzzy():
h1 = ["id", "age"]
h2 = ["id", "age"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [["A2", 24], ["A1", 23], ["A3", 34]]
result = [[True, True], [True, True], [True, True]]
values = [['[A1]:[A1]', '[23]:[23]'], ['[A2]:[A2]', '[24]:[24]'], ['[A3]:[A3]', '[34]:[34]']]
output = comparesv.run(d1, h1, d2, h2, row_match='fuzzy')
assert result == output['results']
assert values == output['values']
def test_extra_column():
h1 = ["id", "age", "name"]
h2 = ["id", "age"]
d1 = [["A1", 23, "Alpha"], ["A2", 24, "Beta"], ["A3", 34, "Gamma"]]
d2 = [["A2", 24], ["A1", 23], ["A3", 34]]
result = [[True, True, False], [True, True, False], [True, True, False]]
values = [['[A1]:[A1]', '[23]:[23]', '[Alpha]:[]'], ['[A2]:[A2]', '[24]:[24]', '[Beta]:[]'], ['[A3]:[A3]', '[34]:[34]', '[Gamma]:[]']]
output = comparesv.run(d1, h1, d2, h2, row_match='fuzzy')
assert result == output['results']
assert values == output['values']
def test_include_extra_rows():
h1 = ["id", "age"]
h2 = ["id", "age"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [["A1", 23], ["A2", 24], ["A3", 34], ["A4", 34]]
result = [[True, True], [True, True], [True, True], [False, False]]
values = [['[A1]:[A1]', '[23]:[23]'], ['[A2]:[A2]', '[24]:[24]'], ['[A3]:[A3]', '[34]:[34]'], ['[]:[A4]', '[]:[34]']]
output = comparesv.run(d1, h1, d2, h2, include_addnl_rows=True)
assert result == output['results']
assert values == output['values']
def test_include_extra_column():
h1 = ["id", "age"]
h2 = ["id", "age", "name"]
d1 = [["A2", 24], ["A1", 23], ["A3", 34]]
d2 = [["A1", 23, "Alpha"], ["A2", 24, "Beta"], ["A3", 34, "Gamma"]]
output = comparesv.run(d1, h1, d2, h2, include_addnl_columns=True)
result = [[False, False, False], [False, False, False], [True, True, False]]
values = [['[A2]:[A1]', '[24]:[23]', '[]:[Alpha]'],
['[A1]:[A2]', '[23]:[24]', '[]:[Beta]'],
['[A3]:[A3]', '[34]:[34]', '[]:[Gamma]']]
assert result == output['results']
assert values == output['values']
def test_basic_case():
h1 = ["id", "age"]
h2 = ["id", "age"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [["a1", 23], ["a2", 24], ["a3", 34]]
result = [[True, True], [True, True], [True, True]]
values = [['[A1]:[a1]', '[23]:[23]'], ['[A2]:[a2]', '[24]:[24]'], ['[A3]:[a3]', '[34]:[34]']]
output = comparesv.run(d1, h1, d2, h2, ignore_case=True)
assert result == output['results']
assert values == output['values']
def test_include_rows():
h1 = ["id", "age"]
h2 = ["id", "age"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [["A1", 23], ["A2", 24], ["A3", 34],["A4", 34]]
result = [[True, True], [True, True], [True, True], [False, False]]
values = [['[A1]:[A1]', '[23]:[23]'], ['[A2]:[A2]', '[24]:[24]'], ['[A3]:[A3]', '[34]:[34]'], ['[]:[A4]', '[]:[34]']]
output = comparesv.run(d1, h1, d2, h2, include_addnl_rows=True)
assert result == output['results']
assert values == output['values']
def test_include_columns():
h1 = ["id", "age"]
h2 = ["id", "age","gender"]
d1 = [["A1", 23], ["A2", 24], ["A3", 34]]
d2 = [["A1", 23,"M"], ["A2", 24,"F"], ["A3", 34,"O"]]
result = [[True, True, False], [True, True, False], [True, True, False]]
values = [['[A1]:[A1]', '[23]:[23]', '[]:[M]'],
['[A2]:[A2]', '[24]:[24]', '[]:[F]'],
['[A3]:[A3]', '[34]:[34]', '[]:[O]']]
headers = ['id', 'age', 'gender']
output = comparesv.run(d1, h1, d2, h2, include_addnl_columns=True)
assert result == output['results']
assert values == output['values']
assert headers == output['headers']