def test_remote_env_not_called_if_study_has_already_a_jobid(self):
        self.remote_env.submit_job = mock.Mock()
        study = StudyDTO(path="hello")
        study.job_id = 42

        self.study_submitter.submit_job(study)

        self.remote_env.submit_job.assert_not_called()
Beispiel #2
0
 def test_given_tinydb_document_when_doc_to_study_called_then_return_corresponding_study(
     self, ):
     # given
     expected_study = StudyDTO(path="path")
     expected_study.job_id = 42
     expected_study.n_cpu = 999
     doc = tinydb.database.Document(expected_study.__dict__, 42)
     # when
     output_study = DataRepoTinydb.doc_to_study(doc)
     # then
     assert expected_study.__dict__ == output_study.__dict__
Beispiel #3
0
 def test_is_job_id_inside_database_returns_true_only_if_one_job_id_is_found(
         self):
     # given
     repo = DataRepoTinydb("")
     type(repo).db = mock.PropertyMock()
     study_dto = StudyDTO(path="path")
     study_dto.job_id = 6381
     repo.get_list_of_studies = mock.Mock(return_value=[study_dto])
     repo.save_study(study_dto)
     # when
     output = repo.is_job_id_inside_database(6381)
     # then
     assert output is True
    def test_remote_env_is_called_if_study_has_no_jobid(self):
        self.remote_env.submit_job = mock.Mock(return_value=42)
        study = StudyDTO(path="hello")
        study.zipfile_path = "ciao.zip"
        study.job_id = None

        new_study = self.study_submitter.submit_job(study)

        self.remote_env.submit_job.assert_called_once()
        first_call = self.remote_env.submit_job.call_args_list[0]
        first_argument = first_call[0][0]
        assert asdict(first_argument) == asdict(study)
        assert new_study.job_id is 42
 def started_study(self):
     study = StudyDTO(path=Path("path") / "hello")
     study.started = True
     study.job_id = 42
     study.job_log_dir = "ROOT_LOG_DIR"
     return study