@@ -324,39 +324,52 @@ def test_singularity_get_image_from_sandbox(monkeypatch: pytest.MonkeyPatch, tmp
324324
325325 workdir = tmp_path / "working_dir"
326326 workdir .mkdir ()
327- # build a sandbox image
328327 repo_path = workdir / "container_repo"
329328 repo_path .mkdir ()
330329 image_path = repo_path / "alpine"
331330 image_path .mkdir ()
332331
333332 # directory exists but is not an image
334333 monkeypatch .setattr ("cwltool.singularity._inspect_singularity_image" , lambda * args , ** kwargs : False )
335- assert not SingularityCommandLineJob (
334+ req = {"class" : "DockerRequirement" , "dockerPull" : f"{ image_path } " }
335+ res = SingularityCommandLineJob (
336336 builder , {}, CommandLineTool .make_path_mapper , [], [], ""
337337 ).get_image (
338- {
339- "class" : "DockerRequirement" ,
340- "dockerPull" : f"{ image_path } " ,
341- },
338+ req ,
342339 pull_image = False ,
343340 tmp_outdir_prefix = str (tmp_outdir_prefix ),
344341 force_pull = False ,
345342 )
343+ assert req ["dockerPull" ].startswith ("docker://" )
344+ assert res is False
346345
347346 # directory exists and is an image:
348347 monkeypatch .setattr ("cwltool.singularity._inspect_singularity_image" , lambda * args , ** kwargs : True )
349- assert SingularityCommandLineJob (
348+ req = {"class" : "DockerRequirement" , "dockerPull" : f"{ image_path } " }
349+ res = SingularityCommandLineJob (
350350 builder , {}, CommandLineTool .make_path_mapper , [], [], ""
351351 ).get_image (
352- {
353- "class" : "DockerRequirement" ,
354- "dockerPull" : f"{ image_path } " ,
355- },
352+ req ,
353+ pull_image = False ,
354+ tmp_outdir_prefix = str (tmp_outdir_prefix ),
355+ force_pull = False ,
356+ )
357+ assert req ["dockerPull" ] == str (image_path )
358+ assert req ["dockerImageId" ] == str (image_path )
359+ assert res
360+
361+ # test that dockerImageId is set and image exists:
362+ req = {"class" : "DockerRequirement" , "dockerImageId" : f"{ image_path } " }
363+ res = SingularityCommandLineJob (
364+ builder , {}, CommandLineTool .make_path_mapper , [], [], ""
365+ ).get_image (
366+ req ,
356367 pull_image = False ,
357368 tmp_outdir_prefix = str (tmp_outdir_prefix ),
358369 force_pull = False ,
359370 )
371+ assert req ["dockerImageId" ] == str (image_path )
372+ assert res
360373
361374
362375def test_docker_tmpdir_prefix (tmp_path : Path ) -> None :
0 commit comments