def test_given_a_non_submitted_study_then_get_job_state_flags_is_not_called(): # given my_study = StudyDTO(path="study_path", job_id=None) remote_env_mock = mock.Mock() remote_env_mock.get_job_state_flags = mock.Mock() display = mock.Mock() display.show_error = mock.Mock() state_updater = StateUpdater(remote_env_mock, display) message = f'"{Path(my_study.path).name}": Job was not submitted' # when state_updater.run(my_study) # then remote_env_mock.get_job_state_flags.assert_not_called() display.show_error.assert_called_once_with(message, mock.ANY)
def test_given_a_done_study_then_get_job_state_flags_is_not_called(): # given my_study = StudyDTO(path="study_path", job_id=42, done=True) remote_env_mock = mock.Mock() remote_env_mock.get_job_state_flags = mock.Mock(return_value=(True, False, False)) display = mock.Mock() display.show_message = mock.Mock() state_updater = StateUpdater(remote_env_mock, display) message = ( f'"{Path(my_study.path).name}" (JOBID={my_study.job_id}): everything is done' ) # when state_updater.run(my_study) # then remote_env_mock.get_job_state_flags.assert_not_called() display.show_message.assert_called_once_with(message, mock.ANY)
def test_given_a_submitted_study_then_study_flags_are_updated( started_flag, finished_flag, with_error_flag, status): # given my_study = StudyDTO(path="study_path", job_id=42) remote_env_mock = mock.Mock() display = mock.Mock() remote_env_mock.get_job_state_flags = mock.Mock( return_value=(started_flag, finished_flag, with_error_flag)) display.show_message = mock.Mock() state_updater = StateUpdater(remote_env_mock, display) message = f'"{Path(my_study.path).name}" (JOBID={my_study.job_id}): {status}' # when study_test = state_updater.run(my_study) # then remote_env_mock.get_job_state_flags.assert_called_once_with(my_study) display.show_message.assert_called_once_with(message, mock.ANY) assert study_test.started == started_flag assert study_test.finished == finished_flag assert study_test.with_error == with_error_flag assert study_test.job_state == status