Skip to content

Commit

Permalink
Added INFO satus and collect report level keeps only valid statuses
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Waltlova <[email protected]>
  • Loading branch information
andywaltlova committed Sep 4, 2023
1 parent 2bddbe5 commit ad38183
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ disable=
missing-docstring,
too-few-public-methods,
broad-except,
bad-continuation,
# python3 specific disabled
useless-object-inheritance,
super-with-arguments,
Expand Down
8 changes: 6 additions & 2 deletions scripts/preconversion_assessment_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def to_dict(self):

STATUS_CODE = {
"SUCCESS": 0,
"INFO": 25,
"WARNING": 51,
"SKIP": 101,
"OVERRIDABLE": 152,
Expand Down Expand Up @@ -87,8 +88,11 @@ def collect_report_level(action_results):
for message in value["messages"]:
action_level_combined.append(message["level"])

action_level_combined.sort(key=lambda status: STATUS_CODE[status], reverse=True)
return action_level_combined
valid_action_levels = [
level for level in action_level_combined if level in STATUS_CODE
]
valid_action_levels.sort(key=lambda status: STATUS_CODE[status], reverse=True)
return valid_action_levels


def gather_textual_report():
Expand Down
20 changes: 19 additions & 1 deletion tests/preconversion_assessment/test_collect_report_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,26 @@
}


def test_collect_report_level():
def test_collect_report_level_expected():
"""Should be sorted descending from the 'worst' status"""
expected_output = ["ERROR", "ERROR", "WARNING", "WARNING", "SUCCESS", "SUCCESS"]
result = collect_report_level(SAMPLE_ACTION_RESULTS)
assert result == expected_output


def test_collect_report_level_unknown_status():
"""Should ignore unknown statuses in report"""
expected_output = ["ERROR", "WARNING", "WARNING", "INFO", "SUCCESS"]

action_results_test = {
"action1": {
"result": {"level": "ERROR"},
"messages": [{"level": "SUCCESS"}, {"level": "WARNING"}],
},
"action2": {
"result": {"level": "WARNING"},
"messages": [{"level": "FOO"}, {"level": "INFO"}],
},
}
result = collect_report_level(action_results_test)
assert result == expected_output

0 comments on commit ad38183

Please sign in to comment.