|
| 1 | +import asyncio |
1 | 2 | import filecmp
|
2 | 3 | import os
|
3 | 4 | import shutil
|
4 | 5 | import tarfile
|
5 |
| -import time |
6 |
| -from pathlib import Path |
7 |
| -from unittest.mock import patch |
| 6 | +from unittest.mock import MagicMock, patch |
8 | 7 |
|
9 | 8 | import pytest
|
10 | 9 |
|
@@ -41,23 +40,25 @@ async def test_copy_from_staging():
|
41 | 40 | }
|
42 | 41 | output_dir = "jobs/1"
|
43 | 42 | with patch("jupyter_scheduler.job_files_manager.Downloader") as mock_downloader:
|
44 |
| - with patch("jupyter_scheduler.job_files_manager.Process") as mock_process: |
45 |
| - with patch("jupyter_scheduler.scheduler.Scheduler") as mock_scheduler: |
46 |
| - mock_scheduler.get_job.return_value = job |
47 |
| - mock_scheduler.get_staging_paths.return_value = staging_paths |
48 |
| - mock_scheduler.get_local_output_path.return_value = output_dir |
49 |
| - mock_scheduler.get_job_filenames.return_value = job_filenames |
50 |
| - manager = JobFilesManager(scheduler=mock_scheduler) |
51 |
| - await manager.copy_from_staging(1) |
52 |
| - |
53 |
| - mock_downloader.assert_called_once_with( |
54 |
| - output_formats=job.output_formats, |
55 |
| - output_filenames=job_filenames, |
56 |
| - staging_paths=staging_paths, |
57 |
| - output_dir=output_dir, |
58 |
| - redownload=False, |
59 |
| - include_staging_files=None, |
60 |
| - ) |
| 43 | + with patch("jupyter_scheduler.scheduler.Scheduler") as mock_scheduler: |
| 44 | + mock_future = asyncio.Future() |
| 45 | + mock_future.set_result(MagicMock()) |
| 46 | + mock_scheduler.dask_client_future = mock_future |
| 47 | + mock_scheduler.get_job.return_value = job |
| 48 | + mock_scheduler.get_staging_paths.return_value = staging_paths |
| 49 | + mock_scheduler.get_local_output_path.return_value = output_dir |
| 50 | + mock_scheduler.get_job_filenames.return_value = job_filenames |
| 51 | + manager = JobFilesManager(scheduler=mock_scheduler) |
| 52 | + await manager.copy_from_staging(1) |
| 53 | + |
| 54 | + mock_downloader.assert_called_once_with( |
| 55 | + output_formats=job.output_formats, |
| 56 | + output_filenames=job_filenames, |
| 57 | + staging_paths=staging_paths, |
| 58 | + output_dir=output_dir, |
| 59 | + redownload=False, |
| 60 | + include_staging_files=None, |
| 61 | + ) |
61 | 62 |
|
62 | 63 |
|
63 | 64 | @pytest.fixture
|
|
0 commit comments