|
5 | 5 | from ddsc.core.pathfilter import PathFilter |
6 | 6 | import queue |
7 | 7 | import requests |
8 | | -from mock.mock import patch, Mock, call, mock_open |
| 8 | +from mock.mock import patch, Mock, call, mock_open, ANY |
9 | 9 |
|
10 | 10 |
|
11 | 11 | class TestFileHash(TestCase): |
@@ -206,7 +206,7 @@ def test_run(self, mock_time, mock_file_download_state, mock_print, mock_os, moc |
206 | 206 | self.project.get_project_files_generator.return_value = [ |
207 | 207 | (mock_project_file, {DDS_TOTAL_HEADER: 1}) |
208 | 208 | ] |
209 | | - mock_pool = mock_multiprocessing.Pool.return_value.__enter__.return_value |
| 209 | + mock_pool = mock_multiprocessing.Pool.return_value |
210 | 210 | mock_apply_async = mock_pool.apply_async |
211 | 211 | mock_apply_async.return_value.get.return_value.status.get_status_line.return_value = 'Hash Status Line' |
212 | 212 |
|
@@ -262,14 +262,14 @@ def test_download_files(self, mock_multiprocessing): |
262 | 262 |
|
263 | 263 | # Expected behavior is to download file 1, wait for that to finish, download file 2, then wait for one more time |
264 | 264 | manager.assert_has_calls([ |
265 | | - call.download_file(mock_pool, 'project_file1_obj'), |
| 265 | + call.download_file(ANY, 'project_file1_obj'), |
266 | 266 | call.work_queue_is_full(), |
267 | | - call.wait_for_and_retry_failed_downloads(mock_pool), |
| 267 | + call.wait_for_and_retry_failed_downloads(ANY), |
268 | 268 | call.work_queue_is_full(), |
269 | | - call.download_file(mock_pool, 'project_file2_obj'), |
| 269 | + call.download_file(ANY, 'project_file2_obj'), |
270 | 270 | call.work_queue_is_full(), |
271 | 271 | call.work_queue_is_not_empty(), |
272 | | - call.wait_for_and_retry_failed_downloads(mock_pool), |
| 272 | + call.wait_for_and_retry_failed_downloads(ANY), |
273 | 273 | call.work_queue_is_not_empty() |
274 | 274 | ]) |
275 | 275 |
|
@@ -389,14 +389,15 @@ def test_get_project_files_with_filter_warnings(self, mock_print, mock_multiproc |
389 | 389 | @patch('ddsc.core.download.os') |
390 | 390 | @patch('ddsc.core.download.FileDownloadState') |
391 | 391 | def test_download_file(self, mock_file_download_state, mock_os, mock_multiprocessing): |
| 392 | + mock_os.path.exists.return_value = False |
392 | 393 | mock_pool = Mock() |
393 | 394 | mock_project_file = Mock(file_url={'host': 'somehost', 'url': 'someurl'}) |
394 | 395 | mock_project_file.get_local_path.return_value = '/tmp/data.out' |
395 | 396 | project_file_downloader = ProjectFileDownloader(self.config, self.dest_directory, self.project, |
396 | 397 | path_filter=None) |
397 | 398 | project_file_downloader._download_file(mock_pool, mock_project_file) |
398 | 399 | mock_os.path.dirname.assert_called_with("/tmp/data.out") |
399 | | - mock_os.makedirs.assert_called_with(mock_os.path.dirname.return_value, exist_ok=True) |
| 400 | + mock_os.makedirs.assert_called_with(mock_os.path.dirname.return_value) |
400 | 401 | mock_file_download_state.assert_called_with(mock_project_file, '/tmp/data.out', self.config) |
401 | 402 | mock_pool.apply_async.assert_called_with(download_file, (mock_file_download_state.return_value, |
402 | 403 | project_file_downloader.message_queue)) |
|
0 commit comments