diff --git a/sceptre/cli/update.py b/sceptre/cli/update.py index 155e135a3..419ffc66a 100644 --- a/sceptre/cli/update.py +++ b/sceptre/cli/update.py @@ -66,7 +66,10 @@ def update_command( for status in list(statuses.values()): # Exit if change set fails to create - if status not in (StackChangeSetStatus.READY, StackChangeSetStatus.NO_CHANGES): + if status not in ( + StackChangeSetStatus.READY, + StackChangeSetStatus.NO_CHANGES, + ): write("Failed to create change set", context.output_format) exit(1) diff --git a/sceptre/plan/actions.py b/sceptre/plan/actions.py index 2126f82fb..478c16df1 100644 --- a/sceptre/plan/actions.py +++ b/sceptre/plan/actions.py @@ -925,18 +925,17 @@ def _get_cs_status(self, change_set_name): ] and cs_exec_status in ["UNAVAILABLE", "AVAILABLE"]: return StackChangeSetStatus.PENDING elif ( - cs_status == "FAILED" and - cs_reason is not None and - self.change_set_creation_failed_due_to_no_changes(cs_reason) + cs_status == "FAILED" + and cs_reason is not None + and self.change_set_creation_failed_due_to_no_changes(cs_reason) ): return StackChangeSetStatus.NO_CHANGES - elif ( - cs_status in ["DELETE_COMPLETE", "FAILED"] or - cs_exec_status in [ - "EXECUTE_IN_PROGRESS", "EXECUTE_COMPLETE", - "EXECUTE_FAILED", "OBSOLETE" - ] - ): + elif cs_status in ["DELETE_COMPLETE", "FAILED"] or cs_exec_status in [ + "EXECUTE_IN_PROGRESS", + "EXECUTE_COMPLETE", + "EXECUTE_FAILED", + "OBSOLETE", + ]: return StackChangeSetStatus.DEFUNCT else: # pragma: no cover raise Exception("This else should not be reachable.") diff --git a/tests/test_actions.py b/tests/test_actions.py index 379f3967e..c3c5a007d 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -1169,12 +1169,10 @@ def test_get_cs_status_handles_all_statuses(self, mock_describe_change_set): mock_describe_change_set.return_value = { "Status": "FAILED", "StatusReason": "The submitted information didn't contain changes. " - "Submit different information to create a change set.", - "ExecutionStatus": "UNAVAILABLE" + "Submit different information to create a change set.", + "ExecutionStatus": "UNAVAILABLE", } - response = self.actions._get_cs_status( - sentinel.change_set_name - ) + response = self.actions._get_cs_status(sentinel.change_set_name) assert response == scss.NO_CHANGES for status in return_values["Status"]: diff --git a/tests/test_cli/test_cli_commands.py b/tests/test_cli/test_cli_commands.py index 439760314..08403e05e 100644 --- a/tests/test_cli/test_cli_commands.py +++ b/tests/test_cli/test_cli_commands.py @@ -515,7 +515,8 @@ def test_stack_commands(self, command, success, yes_flag, exit_code): assert result.exit_code == exit_code @pytest.mark.parametrize( - "change_set_status,yes_flag,exit_code,verbose_flag", [ + "change_set_status,yes_flag,exit_code,verbose_flag", + [ (StackChangeSetStatus.READY, True, 0, True), (StackChangeSetStatus.READY, True, 0, False), (StackChangeSetStatus.READY, False, 0, True), @@ -528,9 +529,11 @@ def test_stack_commands(self, command, success, yes_flag, exit_code): (StackChangeSetStatus.DEFUNCT, False, 1, False), (StackChangeSetStatus.DEFUNCT, True, 1, False), (StackChangeSetStatus.DEFUNCT, False, 1, True), - ] + ], ) - def test_update_with_change_set(self, change_set_status, yes_flag, exit_code, verbose_flag): + def test_update_with_change_set( + self, change_set_status, yes_flag, exit_code, verbose_flag + ): create_command = self.mock_stack_actions.create_change_set wait_command = self.mock_stack_actions.wait_for_cs_completion execute_command = self.mock_stack_actions.execute_change_set @@ -556,10 +559,10 @@ def test_update_with_change_set(self, change_set_status, yes_flag, exit_code, ve "Replacement": "Replacement", "ResourceType": "ResourceType", "Scope": "Scope", - "VerboseProperty": "VerboseProperty" + "VerboseProperty": "VerboseProperty", } } - ] + ], } if not verbose_flag: @@ -581,14 +584,14 @@ def test_update_with_change_set(self, change_set_status, yes_flag, exit_code, ve result = self.runner.invoke(cli, **kwargs) change_set_name = create_command.call_args[0][0] - assert 'change-set' in change_set_name + assert "change-set" in change_set_name - assert wait_command.called_with(change_set_name) - assert delete_command.called_with(change_set_name) + wait_command.assert_called_once_with(change_set_name) + delete_command.assert_called_once_with(change_set_name) if change_set_status == StackChangeSetStatus.READY: - assert execute_command.called_with(change_set_name) - assert describe_command.called_with(change_set_name) + execute_command.assert_called_once_with(change_set_name) + describe_command.assert_called_once_with(change_set_name) output = result.output.splitlines()[0] assert yaml.safe_load(output) == response @@ -601,7 +604,8 @@ def test_update_with_change_set(self, change_set_status, yes_flag, exit_code, ve assert result.exit_code == exit_code @pytest.mark.parametrize( - "command, ignore_dependencies", [ + "command, ignore_dependencies", + [ ("create", True), ("create", False), ("delete", True),