Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #63

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pleskdistup/actions/common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,5 +652,5 @@ def _do_check(self) -> bool:
if len(kernel_devel_packages) <= 1:
return True

self.description = self.description.format("\n\t- ".join([pkg[0] + "-" + pkg[1] for pkg, _ in kernel_devel_packages]))
self.description = self.description.format("\n\t- ".join([pkg + "-" + ver for pkg, ver in kernel_devel_packages]))
return False
2 changes: 1 addition & 1 deletion pleskdistup/common/src/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def __enter__(self):
def __exit__(self, *kwargs):
# Do not remove the actions data if an error occurs because
# customer will likely want to retry after correcting the error on their end
if self.error is not None and os.path.exists(self.path_to_actions_data):
if not self.is_failed() and os.path.exists(self.path_to_actions_data):
os.remove(self.path_to_actions_data)

def _get_flow(self) -> typing.Dict[str, typing.List[ActiveAction]]:
Expand Down
20 changes: 20 additions & 0 deletions pleskdistup/common/tests/actionstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,26 @@ def test_finish_skip_based_on_skip_saved_state(self):
def test_finish_skip_based_on_failed_saved_state(self):
check_saved_state("finish", "test_finish_skip_based_on_failed_saved_state", "failed", False)

def test_actions_json_removed(self):
simple_action = SimpleAction()
simple_action._post_action = mock.Mock(return_value=action.ActionResult())
with FinishActionsFlowForTests({"test_one_simple_action": [simple_action]}) as flow:
flow.validate_actions()
flow.pass_actions()

simple_action._post_action.assert_called_once()
self.assertFalse(os.path.exists("actions.json"))

def test_actions_json_not_removed_on_fail(self):
simple_action = SimpleAction()
simple_action._post_action = mock.Mock(return_value=action.ActionResult(action.ActionState.FAILED))
with FinishActionsFlowForTests({"test_one_simple_action": [simple_action]}) as flow:
flow.validate_actions()
flow.pass_actions()

simple_action._post_action.assert_called_once()
self.assertTrue(os.path.exists("actions.json"))


class RevertActionsFlowForTests(action.RevertActionsFlow):
def __init__(self, stages):
Expand Down
Loading