def setUp(self): self._command = PauseUpdate() self._mock_options = mock_verb_options(self._command) self._mock_options.jobspec = self.TEST_JOBKEY self._fake_context = FakeAuroraCommandContext() self._fake_context.set_options(self._mock_options) self._mock_api = self._fake_context.get_api('UNUSED')
class TestPauseUpdate(AuroraClientCommandTest): def setUp(self): self._command = PauseUpdate() self._mock_options = mock_verb_options(self._command) self._mock_options.jobspec = self.TEST_JOBKEY self._fake_context = FakeAuroraCommandContext() self._fake_context.set_options(self._mock_options) self._mock_api = self._fake_context.get_api('UNUSED') def test_pause_update_command_line_succeeds(self): self._mock_api.query_job_updates.return_value = get_status_query_response() self._mock_api.pause_job_update.return_value = self.create_simple_success_response() self._mock_options.message = 'hello' assert self._command.execute(self._fake_context) == EXIT_OK assert self._mock_api.query_job_updates.mock_calls == [ call(update_statuses=ACTIVE_JOB_UPDATE_STATES, job_key=self.TEST_JOBKEY)] assert self._mock_api.pause_job_update.mock_calls == [call(UPDATE_KEY, 'hello')] assert self._fake_context.get_out() == ["Update has been paused."] assert self._fake_context.get_err() == [] def test_pause_update_command_line_error(self): self._mock_api.query_job_updates.return_value = get_status_query_response() self._mock_api.pause_job_update.return_value = self.create_error_response() with pytest.raises(Context.CommandError): self._command.execute(self._fake_context) assert self._mock_api.query_job_updates.mock_calls == [ call(update_statuses=ACTIVE_JOB_UPDATE_STATES, job_key=self.TEST_JOBKEY)] assert self._mock_api.pause_job_update.mock_calls == [call(UPDATE_KEY, None)] assert self._fake_context.get_out() == [] assert self._fake_context.get_err() == ["Failed to pause update due to error:", "\tWhoops"]