Skip to content

Commit 41f9d72

Browse files
committed
synth pytest
1 parent bca7298 commit 41f9d72

2 files changed

Lines changed: 153 additions & 1 deletion

File tree

aci-preupgrade-validation-script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def updateWithResults(self, result, recommended_action, reason, header, footer,
9393
self.criticality = "warning"
9494

9595
# FailureDetails
96-
if result != PASS:
96+
if result not in [NA, PASS]:
9797
self.passed = False
9898
self.recommended_action = recommended_action
9999
self.failureDetails["fail_type"] = result
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import pytest
2+
import importlib
3+
4+
script = importlib.import_module("aci-preupgrade-validation-script")
5+
6+
7+
@pytest.mark.parametrize(
8+
"name, description, result, recommended_action, reason, header, footer, column, row, unformatted_column, unformatted_rows, expected_show, expected_criticality, expected_passed",
9+
[
10+
# Check 1: NA
11+
(
12+
"NA",
13+
"",
14+
script.NA,
15+
"",
16+
"",
17+
"",
18+
"",
19+
["col1", "col2"],
20+
[["row1", "row2"], ["row3", "row4"]],
21+
["col1", "col2"],
22+
[["row1", "row2"], ["row3", "row4"]],
23+
False,
24+
"informational",
25+
True
26+
),
27+
# Check 2: PASS
28+
(
29+
"PASS",
30+
"",
31+
script.PASS,
32+
"",
33+
"",
34+
"",
35+
"",
36+
[],
37+
[],
38+
[],
39+
[],
40+
True,
41+
"informational",
42+
True
43+
),
44+
# Check 3: POST
45+
(
46+
"POST",
47+
"",
48+
script.POST,
49+
"reboot",
50+
"test reason",
51+
"test header",
52+
"test footer",
53+
["col1", "col2"],
54+
[["row1", "row2"], ["row3", "row4"]],
55+
["col1", "col2"],
56+
[["row1", "row2"], ["row3", "row4"]],
57+
False,
58+
"informational",
59+
False
60+
),
61+
# Check 4: MANUAL
62+
(
63+
"MANUAL",
64+
"",
65+
script.MANUAL,
66+
"reboot",
67+
"test reason",
68+
"test header",
69+
"test footer",
70+
["col1", "col2"],
71+
[["row1", "row2"], ["row3", "row4"]],
72+
["col1", "col2"],
73+
[["row1", "row2"], ["row3", "row4"]],
74+
True,
75+
"warning",
76+
False
77+
),
78+
# Check 5: ERROR
79+
(
80+
"ERROR",
81+
"",
82+
script.ERROR,
83+
"reboot",
84+
"test reason",
85+
"test header",
86+
"test footer",
87+
["col1", "col2"],
88+
[["row1", "row2"], ["row3", "row4"]],
89+
["col1", "col2"],
90+
[["row1", "row2"], ["row3", "row4"]],
91+
True,
92+
"major",
93+
False
94+
),
95+
# Check 6: FAIL_UF
96+
(
97+
"FAIL_UF",
98+
"",
99+
script.FAIL_UF,
100+
"reboot",
101+
"test reason",
102+
"test header",
103+
"test footer",
104+
["col1", "col2"],
105+
[["row1", "row2"], ["row3", "row4"]],
106+
["col1", "col2"],
107+
[["row1", "row2"], ["row3", "row4"]],
108+
True,
109+
"critical",
110+
False
111+
),
112+
# Check 7: FAIL_O
113+
(
114+
"FAIL_O",
115+
"",
116+
script.FAIL_O,
117+
"reboot",
118+
"test reason",
119+
"test header",
120+
"test footer",
121+
["col1", "col2"],
122+
[["row1", "row2"], ["row3", "row4"]],
123+
["col1", "col2"],
124+
[["row1", "row2"], ["row3", "row4"]],
125+
True,
126+
"critical",
127+
False
128+
),
129+
],
130+
)
131+
def test_syntheticMaintPValidate(
132+
name,
133+
description,
134+
result,
135+
recommended_action,
136+
reason,
137+
header,
138+
footer,
139+
column,
140+
row,
141+
unformatted_column,
142+
unformatted_rows,
143+
expected_show,
144+
expected_criticality,
145+
expected_passed,
146+
):
147+
synth = script.syntheticMaintPValidate(name, description)
148+
synth.updateWithResults(result, recommended_action, reason, header, footer, column, row, unformatted_column, unformatted_rows)
149+
result = synth.buildResult()
150+
assert result["syntheticMaintPValidate"]["attributes"]["showValidation"] == expected_show
151+
assert result["syntheticMaintPValidate"]["attributes"]["criticality"] == expected_criticality
152+
assert result["syntheticMaintPValidate"]["attributes"]["passed"] == expected_passed

0 commit comments

Comments
 (0)