Skip to content

Commit

Permalink
[RHELC-1098] Change Action results so that no information is given in…
Browse files Browse the repository at this point in the history
… SUCCESS results (oamg#900)

* [RHELC-1098] Change Action results so that no information is given in SUCCESS results

* Update convert2rhel/unit_tests/actions/actions_test.py

Co-authored-by: E Gustavsson <[email protected]>

---------

Co-authored-by: E Gustavsson <[email protected]>
  • Loading branch information
pr-watson and Venefilyn authored Oct 31, 2023
1 parent c40d90c commit dfbb8ee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions convert2rhel/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ class ActionResult(ActionMessageBase):
def __init__(
self, level="SUCCESS", id="SUCCESS", title="", description="", diagnosis="", remediation="", variables=None
):
if level == "SUCCESS":
if description or diagnosis or remediation:
raise InvalidMessageError(
"Success results cannot have description, diagnosis or remediation fields set"
)
if not id:
raise InvalidMessageError("Results require the id field")

Expand Down
20 changes: 20 additions & 0 deletions convert2rhel/unit_tests/actions/actions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,26 @@ def test_action_message_success(self, level, id, title, description, diagnosis,
@pytest.mark.parametrize(
("id", "level", "title", "description", "diagnosis", "remediation", "variables", "expected"),
(
(
"SUCCESS",
"SUCCESS",
"Success title",
"Successful description",
"Successful diagnosis",
"Successful remediation",
{},
"Success results cannot have description, diagnosis or remediation fields set",
),
(
"SUCCESS",
"SUCCESS",
"Success title",
"Successful description",
None,
None,
{},
"Success results cannot have description, diagnosis or remediation fields set",
),
(
None,
"ERROR",
Expand Down

0 comments on commit dfbb8ee

Please sign in to comment.