@@ -27,13 +27,6 @@ async def _execute(self):
2727 await asyncio .sleep (0.2 ) # Simulate some work
2828 return {'result' : 123 }
2929
30- class EchoJob (Job [SimpleJobConfig ]):
31-
32- async def _execute (self ):
33- results = await self ._execute_batch (self .config .commands ,
34- args = ['Hello' , 'World!' ])
35- return results .data
36-
3730
3831@pytest .fixture
3932def temp_dir ():
@@ -59,14 +52,8 @@ def test_job_configuration(self):
5952 job = SimpleJob (job_id = "test_001" )
6053 job .configure (SimpleJobConfig (should_fail = True ))
6154 assert job .config is not None
62- assert job .config .batch is None
6355 assert job .config .should_fail == True
6456
65- # Update configs
66- job .configure (SimpleJobConfig (batch = BatchConfig (permissions = '755' )))
67- assert job .config .batch is not None
68- assert job .config .batch .permissions .octal == '0o755'
69-
7057 def test_job_with_config (self ):
7158 """Test job creation with configuration."""
7259 config = SimpleJobConfig ()
@@ -143,78 +130,3 @@ def test_job_registry(self):
143130 # Test cleanup on deletion
144131 job .clear ()
145132 assert job_id not in SimpleJob ._registry
146-
147-
148- # Test batch execution functionality
149- class TestBatchExecution :
150- """Test batch execution functionality of the Job class."""
151-
152- @skipif_not_windows
153- @pytest .mark .parametrize (
154- 'shell, cmd, expected' , [
155- (CmdShell , 'echo "%2"' , '"World!"\n ' ),
156- (PowerShell , 'echo $args[1]' , 'World!\n ' )
157- ], ids = ['cmd' , 'powershell' ])
158- @pytest .mark .asyncio
159- async def test_execute_batch_win (self , temp_dir , shell , cmd , expected ):
160- job = EchoJob (job_id = 'test_win' )
161- job .configure (
162- SimpleJobConfig (
163- job_directory = temp_dir ,
164- commands = [cmd ],
165- batch = BatchConfig (),
166- )
167- )
168-
169- job .config .batch .shell = shell
170-
171- result = await job .run ()
172-
173- assert result .data ['stdout' ] == expected
174- assert result .data ['stderr' ] == ''
175-
176- @skipif_not_linux
177- @pytest .mark .parametrize (
178- 'shell, cmd, expected' , [
179- (BashShell , 'echo "$2"' , 'World!\n ' )
180- ], ids = ['bash' ])
181- @pytest .mark .asyncio
182- async def test_execute_batch_posix (self , temp_dir , shell , cmd , expected ):
183- job = EchoJob (job_id = 'test_posix' )
184- job .configure (
185- SimpleJobConfig (
186- job_directory = temp_dir ,
187- commands = [cmd ],
188- batch = BatchConfig (),
189- )
190- )
191-
192- job .config .batch .shell = shell
193-
194- result = await job .run ()
195-
196- assert result .data ['stdout' ] == expected
197- assert result .data ['stderr' ] == ''
198-
199- @pytest .mark .asyncio
200- async def test_log_stream_to_file (self , temp_dir ):
201- """Test _log_stream_to_file functionality."""
202-
203- job = SimpleJob (job_id = 'test_log_stream_to_file' )
204- # Create a test file
205- test_file = temp_dir / "test_log.txt"
206-
207- # Create a mock stream
208- mock_stream = AsyncMock ()
209- mock_stream .read .side_effect = [b"line1\n " , b"line2\n " , b"" ]
210-
211- # Call _log_stream_to_file
212- await job ._log_stream_to_file (mock_stream , test_file )
213-
214- # Verify file contents
215- assert test_file .exists ()
216- content = test_file .read_bytes ()
217- assert content == b"line1\n line2\n "
218-
219- # Verify stream read calls
220- assert mock_stream .read .call_count == 3
0 commit comments