Skip to content

Commit 750627e

Browse files
committed
all data values to str + pytest case
1 parent 9f55e1c commit 750627e

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ def craftData(column, rows):
958958
raise ValueError("Row length ({}), data: {} does not match column length ({}).".format(r_len, rows[row_entry], c_len))
959959
entry = {}
960960
for col_pos in range(c_len):
961-
entry[column[col_pos]] = rows[row_entry][col_pos]
961+
entry[column[col_pos]] = str(rows[row_entry][col_pos])
962962
data.append(entry)
963963
return data
964964

tests/test_AciResult.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"test reason",
138138
"https://test_doc_url.html",
139139
["col1", "col2", "col3"],
140-
[["row1", "row2", "row3"], ["row4", "row5", "row6"]],
140+
[["row1", "row2", 3], ["row4", "row5", 3]],
141141
[],
142142
[],
143143
True,
@@ -156,7 +156,7 @@
156156
[],
157157
[],
158158
["col1", "col2", "col3"],
159-
[["row1", "row2", "row3"], ["row4", "row5", "row6"]],
159+
[["row1", "row2", 3], ["row4", "row5", 3]],
160160
True,
161161
"critical",
162162
"failed"
@@ -188,7 +188,12 @@ def test_AciResult(
188188
assert data["showValidation"] == expected_show
189189
assert data["severity"] == expected_criticality
190190
assert data["ruleStatus"] == expected_passed
191-
191+
for entry in data["failureDetails"]["data"]:
192+
for vals in entry.values():
193+
assert isinstance(vals, str)
194+
for entry in data["failureDetails"]["unformatted_data"]:
195+
for vals in entry.values():
196+
assert isinstance(vals, str)
192197

193198
@pytest.mark.parametrize(
194199
"headers, data",
@@ -209,8 +214,22 @@ def test_invalid_headers_or_data(headers, data):
209214
@pytest.mark.parametrize(
210215
"headers, data",
211216
[
212-
(["col1", "col2"], [["row1"], ["row2"]]), # Rows are shorter
213-
(["col1"], [["row1", "row2"], ["row3", "row4"]]), # columns are shorter
217+
# Rows are shorter
218+
(
219+
["col1", "col2"],
220+
[
221+
["row1"],
222+
["row2"]
223+
]
224+
),
225+
# columns are shorter
226+
(
227+
["col1"],
228+
[
229+
["row1", "row2"],
230+
["row3", "row4"]
231+
]
232+
),
214233
]
215234
)
216235
def test_mismatched_lengths(headers, data):

0 commit comments

Comments
 (0)