44import tarfile
55import time
66from pathlib import Path
7- from unittest .mock import MagicMock , patch
7+ from unittest .mock import patch
88
99import pytest
1010
@@ -40,20 +40,13 @@ async def test_copy_from_staging():
4040 "input" : "helloworld.ipynb" ,
4141 }
4242 output_dir = "jobs/1"
43-
44- mock_scheduler = MagicMock ()
45- mock_scheduler .get_job .return_value = job
46- mock_scheduler .get_staging_paths .return_value = staging_paths
47- mock_scheduler .get_local_output_path .return_value = output_dir
48- mock_scheduler .get_job_filenames .return_value = job_filenames
49-
50- mock_context = MagicMock ()
51- mock_process = MagicMock ()
52- mock_context .Process .return_value = mock_process
53-
5443 with patch ("jupyter_scheduler.job_files_manager.Downloader" ) as mock_downloader :
55- with patch ("jupyter_scheduler.scheduler.Scheduler" , return_value = mock_scheduler ):
56- with patch ("multiprocessing.get_context" , return_value = mock_context ):
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
5750 manager = JobFilesManager (scheduler = mock_scheduler )
5851 await manager .copy_from_staging (1 )
5952
@@ -65,7 +58,6 @@ async def test_copy_from_staging():
6558 redownload = False ,
6659 include_staging_files = None ,
6760 )
68- mock_process .start .assert_called_once ()
6961
7062
7163HERE = Path (__file__ ).parent .resolve ()
0 commit comments