def test_run_on_list_calls_run_start__processing_studies_that_are_done(): # given my_study1 = StudyDTO(path="study_path1", job_id=1, done=False) my_study2 = StudyDTO(path="study_path2", job_id=None) my_study3 = StudyDTO(path="study_path3", job_id=2, done=True) study_list = [my_study1, my_study2, my_study3] 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) # when state_updater.run_on_list(study_list) # then welcome_message = "Checking status of the studies:" message1 = f'"{Path(my_study1.path).name}" (JOBID={my_study1.job_id}): Running' message3 = ( f'"{Path(my_study3.path).name}" (JOBID={my_study3.job_id}): everything is done' ) calls = [ call(welcome_message, mock.ANY), call(message3, mock.ANY), call(message1, mock.ANY), ] display.show_message.assert_has_calls(calls)
def test_state_updater_run_on_empty_list_of_studies_write_one_message(): # given study_list = [] remote_env_mock = mock.Mock() display = mock.Mock() state_updater = StateUpdater(remote_env_mock, display) message = "Checking status of the studies:" # when state_updater.run_on_list(study_list) # then display.show_message.assert_called_once_with(message, mock.ANY)
def test_with_a_list_of_one_submitted_study_run_on_list_calls_run_once_on_study( ): # given my_study1 = StudyDTO(path="study_path1", job_id=1) study_list = [my_study1] remote_env_mock = mock.Mock() remote_env_mock.get_job_state_flags = mock.Mock(return_value=(1, 2, 3)) display = mock.Mock() state_updater = StateUpdater(remote_env_mock, display) # when state_updater.run_on_list(study_list) # then remote_env_mock.get_job_state_flags.assert_called_once_with(my_study1)
def test_run_on_list_calls_run_on_all_submitted_studies_of_the_list(): # given my_study1 = StudyDTO(path="study_path1", job_id=1) my_study2 = StudyDTO(path="study_path2", job_id=None) my_study3 = StudyDTO(path="study_path3", job_id=2) study_list = [my_study1, my_study2, my_study3] remote_env_mock = mock.Mock() remote_env_mock.get_job_state_flags = mock.Mock(return_value=(1, 2, 3)) display = mock.Mock() state_updater = StateUpdater(remote_env_mock, display) # when state_updater.run_on_list(study_list) # then calls = [call(my_study1), call(my_study3)] remote_env_mock.get_job_state_flags.assert_has_calls(calls)