@@ -272,6 +272,60 @@ def test_find_container_images_modules(self, tmp_path, mock_fetch_wf_config):
272272
273273 assert "community.wave.seqera.io/library/coreutils:9.5--ae99c88a9b28c264" in download_obj .containers
274274
275+ #
276+ # Test for 'prioritize_direct_download'
277+ #
278+ @with_temporary_folder
279+ def test_prioritize_direct_download (self , tmp_path ):
280+ download_obj = DownloadWorkflow (pipeline = "dummy" , outdir = tmp_path )
281+
282+ # tests deduplication and https priority as well as Seqera Container exception
283+
284+ test_container = [
285+ "https://depot.galaxyproject.org/singularity/ubuntu:22.04" ,
286+ "nf-core/ubuntu:22.04" ,
287+ "biocontainers/umi-transfer:1.5.0--h715e4b3_0" ,
288+ "https://depot.galaxyproject.org/singularity/umi-transfer:1.5.0--h715e4b3_0" ,
289+ "biocontainers/umi-transfer:1.5.0--h715e4b3_0" ,
290+ "quay.io/nf-core/sortmerna:4.3.7--6502243397c065ba" ,
291+ "nf-core/sortmerna:4.3.7--6502243397c065ba" ,
292+ "https://depot.galaxyproject.org/singularity/sortmerna:4.3.7--hdbdd923_1" ,
293+ "https://depot.galaxyproject.org/singularity/sortmerna:4.3.7--hdbdd923_0" ,
294+ "https://depot.galaxyproject.org/singularity/sortmerna:4.2.0--h9ee0642_1" ,
295+ "https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/63/6397750e9730a3fbcc5b4c43f14bd141c64c723fd7dad80e47921a68a7c3cd21/data" ,
296+ "https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/c2/c262fc09eca59edb5a724080eeceb00fb06396f510aefb229c2d2c6897e63975/data" ,
297+ ]
298+
299+ result = download_obj .prioritize_direct_download (test_container )
300+
301+ # Verify that the priority works for regular https downloads (https encountered first)
302+ assert "https://depot.galaxyproject.org/singularity/ubuntu:22.04" in result
303+ assert "nf-core/ubuntu:22.04" not in result
304+
305+ # Verify that the priority works for regular https downloads (https encountered second)
306+ assert "biocontainers/umi-transfer:1.5.0--h715e4b3_0" not in result
307+ assert "https://depot.galaxyproject.org/singularity/umi-transfer:1.5.0--h715e4b3_0" in result
308+
309+ # Verify that the priority works for images with and without explicit registry
310+ # No priority here, though - the first is retained.
311+ assert "nf-core/sortmerna:4.3.7--6502243397c065ba" in result
312+ assert "quay.io/nf-core/sortmerna:4.3.7--6502243397c065ba" not in result
313+
314+ # Verify that different versions of the same tool and different build numbers are retained
315+ assert "https://depot.galaxyproject.org/singularity/sortmerna:4.3.7--hdbdd923_1" in result
316+ assert "https://depot.galaxyproject.org/singularity/sortmerna:4.3.7--hdbdd923_0" in result
317+ assert "https://depot.galaxyproject.org/singularity/sortmerna:4.2.0--h9ee0642_1" in result
318+
319+ # Verify that Seqera containers are not deduplicated
320+ assert (
321+ "https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/63/6397750e9730a3fbcc5b4c43f14bd141c64c723fd7dad80e47921a68a7c3cd21/data"
322+ in result
323+ )
324+ assert (
325+ "https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/c2/c262fc09eca59edb5a724080eeceb00fb06396f510aefb229c2d2c6897e63975/data"
326+ in result
327+ )
328+
275329 #
276330 # Tests for 'singularity_pull_image'
277331 #
0 commit comments