def test_download_remote_challenge_data_package_with_retry_retry_neg(self): params = D3RParameters() task = ExternalDataSubmissionTask('/foo', 'yo', 'hi', params) task.set_download_max_retry_count(-1) task.set_download_retry_sleep(0) try: task._download_remote_challenge_data_package_with_retry() self.fail('Expected ChallengePackageDownloadError') except ChallengePackageDownloadError as e: self.assertEqual(str(e), 'Unable to download hi')
def test_download_remote_challenge_data_package_with_1st_retry_false(self): temp_dir = tempfile.mkdtemp() try: params = D3RParameters() pkg = '/remote/celpp1_2017_dockedresults_yo.tar.gz' task = ExternalDataSubmissionTask(temp_dir, 'yo', pkg, params) task.set_download_retry_sleep(0) task.set_download_max_retry_count(3) mockft = D3RParameters() mockft.connect = Mock() mockft.download_file = Mock() mockft.download_file.side_effect = [False, True] mockft.disconnect = Mock(return_value=None) task.set_file_transfer(mockft) c = task._download_remote_challenge_data_package_with_retry() self.assertEqual(c, 'celpp1_2017_dockedresults_yo.tar.gz') finally: shutil.rmtree(temp_dir)
def test_download_remote_challenge_data_package_with_retry_false(self): temp_dir = tempfile.mkdtemp() try: params = D3RParameters() pkg = '/remote/celpp1_2017_dockedresults_yo.tar.gz' task = ExternalDataSubmissionTask(temp_dir, 'yo', pkg, params) task.set_download_retry_sleep(0) task.set_download_max_retry_count(1) mockft = D3RParameters() mockft.connect = Mock() mockft.download_file = Mock(return_value=False) mockft.disconnect = Mock(return_value=None) task.set_file_transfer(mockft) try: task._download_remote_challenge_data_package_with_retry() except ChallengePackageDownloadError as e: self.assertEqual( str(e), 'Unable to download ' + 'celpp1_2017_dockedresults_yo.tar.gz') finally: shutil.rmtree(temp_dir)