1
|
|
|
from oval_graph.oval_node import OvalNode |
|
|
|
|
2
|
|
|
import oval_graph.evaluate |
3
|
|
|
import tests.any_test_help |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
# AND operator |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
def test_ANDTreeTrue(): |
|
|
|
|
10
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
11
|
|
|
None, "true", 'ANDTreeTrue.json') |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
def test_ANDTreeFalse(): |
|
|
|
|
15
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
16
|
|
|
None, "false", 'ANDTreeFalse.json') |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
def test_ANDTreeError(): |
|
|
|
|
20
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
21
|
|
|
None, "error", 'ANDTreeError.json') |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
def test_ANDTreeUnknown(): |
|
|
|
|
25
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
26
|
|
|
None, "unknown", 'ANDTreeUnknown.json') |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
def test_ANDTreeNoteval(): |
|
|
|
|
30
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
31
|
|
|
None, "noteval", 'ANDTreeNoteval.json') |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
def test_ANDTreeNotappl(): |
|
|
|
|
35
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
36
|
|
|
None, "notappl", 'ANDTreeNotappl.json') |
37
|
|
|
|
38
|
|
|
# ONE operator |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
def test_ONETreeTrue(): |
|
|
|
|
42
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
43
|
|
|
None, "true", 'ONETreeTrue.json') |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
def test_ONETreeFalse(): |
|
|
|
|
47
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
48
|
|
|
None, "false", 'ONETreeFalse.json') |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
def test_ONETreeFalse1(): |
|
|
|
|
52
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
53
|
|
|
None, "false", 'ONETreeFalse1.json') |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
def test_ONETreeError(): |
|
|
|
|
57
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
58
|
|
|
None, "error", 'ONETreeError.json') |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
def test_ONETreeUnknown(): |
|
|
|
|
62
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
63
|
|
|
None, "unknown", 'ONETreeUnknown.json') |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
def test_ONETreeNoteval(): |
|
|
|
|
67
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
68
|
|
|
None, "noteval", 'ONETreeNoteval.json') |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
def test_ONETreeNotappl(): |
|
|
|
|
72
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
73
|
|
|
None, "notappl", 'ONETreeNotappl.json') |
74
|
|
|
|
75
|
|
|
# OR operator |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
def test_ORTreeTrue(): |
|
|
|
|
79
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
80
|
|
|
None, "true", 'ORTreeTrue.json') |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
def test_ORTreeFalse(): |
|
|
|
|
84
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
85
|
|
|
None, "false", 'ORTreeFalse.json') |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
def test_ORTreeError(): |
|
|
|
|
89
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
90
|
|
|
None, "error", 'ORTreeError.json') |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
def test_ORTreeUnknown(): |
|
|
|
|
94
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
95
|
|
|
None, "unknown", 'ORTreeUnknown.json') |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
def test_ORTreeNoteval(): |
|
|
|
|
99
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
100
|
|
|
None, "noteval", 'ORTreeNoteval.json') |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
def test_ORTreeNotappl(): |
|
|
|
|
104
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
105
|
|
|
None, "notappl", 'ORTreeNotappl.json') |
106
|
|
|
|
107
|
|
|
# XOR operator |
108
|
|
|
|
109
|
|
|
|
110
|
|
|
def test_XORTreeTrue(): |
|
|
|
|
111
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
112
|
|
|
None, "true", 'XORTreeTrue.json') |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
def test_XORTreeFalse(): |
|
|
|
|
116
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
117
|
|
|
None, "false", 'XORTreeFalse.json') |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
def test_XORTreeError(): |
|
|
|
|
121
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
122
|
|
|
None, "error", 'XORTreeError.json') |
123
|
|
|
|
124
|
|
|
|
125
|
|
|
def test_XORTreeUnknown(): |
|
|
|
|
126
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
127
|
|
|
None, "unknown", 'XORTreeUnknown.json') |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
def test_XORTreeNoteval(): |
|
|
|
|
131
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
132
|
|
|
None, "noteval", 'XORTreeNoteval.json') |
133
|
|
|
|
134
|
|
|
|
135
|
|
|
def test_XORTreeNotappl(): |
|
|
|
|
136
|
|
|
tests.any_test_help.any_test_treeEvaluation( |
|
|
|
|
137
|
|
|
None, "notappl", 'XORTreeNotappl.json') |
138
|
|
|
|
139
|
|
|
|
140
|
|
|
results_counts = { |
141
|
|
|
'true_cnt': -1, |
142
|
|
|
'false_cnt': -1, |
143
|
|
|
'error_cnt': -1, |
144
|
|
|
'unknown_cnt': -1, |
145
|
|
|
'noteval_cnt': -1, |
146
|
|
|
'notappl_cnt': -1 |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
results_counts1 = { |
150
|
|
|
'true_cnt': 3, |
151
|
|
|
'false_cnt': 3, |
152
|
|
|
'error_cnt': 3, |
153
|
|
|
'unknown_cnt': 0, |
154
|
|
|
'noteval_cnt': -1, |
155
|
|
|
'notappl_cnt': 3 |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
def test_bad_results_counts_for_operator_and(): |
|
|
|
|
160
|
|
|
assert oval_graph.evaluate.oval_operator_and(results_counts) is None |
|
|
|
|
161
|
|
|
|
162
|
|
|
|
163
|
|
|
def test_bad_results_counts_for_operator_one(): |
|
|
|
|
164
|
|
|
assert oval_graph.evaluate.oval_operator_one(results_counts) is None |
|
|
|
|
165
|
|
|
|
166
|
|
|
|
167
|
|
|
def test_bad_results_counts_for_operator_or(): |
|
|
|
|
168
|
|
|
assert oval_graph.evaluate.oval_operator_or(results_counts) is None |
|
|
|
|
169
|
|
|
|
170
|
|
|
|
171
|
|
|
def test_bad_results_counts_for_operator_xor(): |
|
|
|
|
172
|
|
|
assert oval_graph.evaluate.oval_operator_xor(results_counts) is None |
|
|
|
|
173
|
|
|
|
174
|
|
|
|
175
|
|
|
def test_false_noteval_greater_zero(): |
|
|
|
|
176
|
|
|
assert not oval_graph.evaluate.greater_zero(results_counts, 'noteval_cnt') |
|
|
|
|
177
|
|
|
|
178
|
|
|
|
179
|
|
|
def test_false_smaller_then_two(): |
|
|
|
|
180
|
|
|
assert not oval_graph.evaluate.smaller_than_two( |
|
|
|
|
181
|
|
|
results_counts1, 'true_cnt') |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
def test_false_eq_zero_duo(): |
|
|
|
|
185
|
|
|
assert not oval_graph.evaluate.eq_zero_duo( |
|
|
|
|
186
|
|
|
results_counts, 'noteval_cnt', 'error_cnt') |
187
|
|
|
|
188
|
|
|
|
189
|
|
|
def test_false_eq_or_greater_zero_unknown_noteval_notappl(): |
|
|
|
|
190
|
|
|
assert not oval_graph.evaluate.eq_or_greater_zero_unknown_noteval_notappl( |
|
|
|
|
191
|
|
|
results_counts1) |
192
|
|
|
|
193
|
|
|
|
194
|
|
|
def test_false_error_unknown_eq_noteval_greater_zero(): |
|
|
|
|
195
|
|
|
assert not oval_graph.evaluate.error_unknown_eq_noteval_greater_zero( |
|
|
|
|
196
|
|
|
results_counts) |
197
|
|
|
|