def test_run_fail(self): temp_dir = tempfile.mkdtemp() try: params = D3RParameters() pkg = '/remote/celpp1_2017_dockedresults_yo.tar.gz' task = ExternalDataSubmissionTask(temp_dir, 'yo', pkg, params) mockft = D3RParameters() mockft.connect = Mock(side_effect=IOError('error')) mockft.download_file = Mock(return_value=True) mockft.disconnect = Mock(return_value=None) task.set_file_transfer(mockft) task.run() self.assertEqual( task.get_error(), 'Caught exception Unable to ' 'download celpp1_2017_docked' 'results_yo.tar.gz') self.assertEqual( task.get_email_log(), 'Try # 1 of 3 to download ' 'celpp1_2017_dockedresults' '_yo.tar.gz\nTry # 2 of 3 ' 'to download celpp1_2017_d' 'ockedresults_yo.tar.gz\n' 'Try # 3 of 3 to download ' 'celpp1_2017_dockedresults' '_yo.tar.gz\n') finally: shutil.rmtree(temp_dir)
def test_run_unable_to_run_cause_can_run_is_false(self): temp_dir = tempfile.mkdtemp() try: params = D3RParameters() pkg = '/remote/celpp2_3.tar.gz' task = ExternalDataSubmissionTask(temp_dir, 'yo', pkg, params) task.create_dir() task.run() self.assertEqual(task.get_email_log(), None) self.assertEqual(task.get_error(), 'stage.6.yo.extsubmission ' 'already exists and status ' 'is unknown') finally: shutil.rmtree(temp_dir)