|
| 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