Esempio n. 1
0
    def test_file_manager_not_called_if_zip_exists(self):
        self.file_manager.zip_dir_excluding_subdir = mock.Mock()
        study = StudyDTO(path="hello")
        study.zipfile_path = "ciao.zip"

        new_zip = self.study_zipper.zip(study)

        self.file_manager.zip_dir_excluding_subdir.assert_not_called()
        self.display_mock.show_error.assert_not_called()
        self.display_mock.show_message.assert_not_called()
        assert new_zip == study
Esempio n. 2
0
    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
Esempio n. 3
0
    def test_file_manager_is_called_if_zip_doesnt_exist(self):
        self.file_manager.zip_dir_excluding_subdir = mock.Mock(
            return_value=True)
        study_path = "hello"
        study = StudyDTO(path=study_path)
        study.zipfile_path = ""

        new_study = self.study_zipper.zip(study)

        expected_zipfile_path = study.path + "-" + getpass.getuser() + ".zip"
        self.file_manager.zip_dir_excluding_subdir.assert_called_once_with(
            study_path, expected_zipfile_path, "output")
        assert new_study.zipfile_path == expected_zipfile_path