Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d201f0a
Add container load scripts for Docker and Podman
ErikDanielsson Aug 8, 2025
e6827ef
[automated] Update CHANGELOG.md
nf-core-bot Aug 8, 2025
1d7f48e
Update tests
ErikDanielsson Aug 8, 2025
488b7b4
Merge branch 'download-refactor-again' into container-load-scripts
ErikDanielsson Aug 13, 2025
510f566
Create download test folder and move util tests
ErikDanielsson Aug 14, 2025
1a765c4
Move singularity and docker tests
ErikDanielsson Aug 14, 2025
29529ca
Move tests from utils to correct class
ErikDanielsson Aug 14, 2025
7dede8a
Update comments
ErikDanielsson Aug 14, 2025
c7495de
Merge branch 'refactor-download-tests' into container-load-scripts
ErikDanielsson Aug 14, 2025
6215f95
Fix typo
ErikDanielsson Aug 14, 2025
fd6a38f
Merge branch 'download-refactor-again' into refactor-download-tests
ErikDanielsson Aug 14, 2025
44cc2b3
Merge branch 'refactor-download-tests' into container-load-scripts
ErikDanielsson Aug 14, 2025
35a2ad1
Merge branch 'download-refactor-again' into refactor-download-tests
ErikDanielsson Aug 14, 2025
ff681f7
Fix test
ErikDanielsson Aug 14, 2025
e662c2c
Merge branch 'download-refactor-again' into refactor-download-tests
ErikDanielsson Aug 14, 2025
3b187b4
Merge branch 'refactor-download-tests' into container-load-scripts
ErikDanielsson Aug 14, 2025
cb318b2
Merge branch 'dev' into container-load-scripts
JulianFlesch Aug 28, 2025
441a5ec
fix: Remove use of 'jq' for REPO_TAG extraction, which may not be ins…
JulianFlesch Aug 28, 2025
7702073
impr: Fail if docker daemon is not running
JulianFlesch Aug 28, 2025
350555a
impr: Fail if no podman installation is found or no podman machine is…
JulianFlesch Aug 28, 2025
239953e
impr: Fail if docker cmd not found
JulianFlesch Aug 28, 2025
1fa9c0d
Merge branch 'dev' into container-load-scripts
JulianFlesch Aug 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move tests from utils to correct class
  • Loading branch information
ErikDanielsson committed Aug 14, 2025
commit 29529cae7280b9474149e8ffeeb5145e5fadcaec
100 changes: 100 additions & 0 deletions tests/pipelines/download/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,106 @@
import unittest

import pytest
import rich.progress_bar
import rich.table
import rich.text

from nf_core.pipelines.download.container_fetcher import ContainerProgress


class ContainerProgressTest(unittest.TestCase):
@pytest.fixture(autouse=True)
def use_caplog(self, caplog):
self._caplog = caplog

#
# Test for 'utils..add/update_main_task'
#
def test_download_progress_main_task(self):
with ContainerProgress() as progress:
# No task initially
assert progress.tasks == []

# Add a task, it should be there
task_id = progress.add_main_task(total=42)
assert task_id == 0
assert len(progress.tasks) == 1
assert progress.task_ids[0] == task_id
assert progress.tasks[0].total == 42

# Add another task, there should now be two
other_task_id = progress.add_task("Another task", total=28)
assert other_task_id == 1
assert len(progress.tasks) == 2
assert progress.task_ids[1] == other_task_id
assert progress.tasks[1].total == 28

progress.update_main_task(total=35)
assert progress.tasks[0].total == 35
assert progress.tasks[1].total == 28

#
# Test for 'utils.DownloadProgress.sub_task'
#
def test_download_progress_sub_task(self):
with ContainerProgress() as progress:
# No task initially
assert progress.tasks == []

# Add a sub-task, it should be there
with progress.sub_task("Sub-task", total=42) as sub_task_id:
assert sub_task_id == 0
assert len(progress.tasks) == 1
assert progress.task_ids[0] == sub_task_id
assert progress.tasks[0].total == 42

# The sub-task should be gone now
assert progress.tasks == []

# Add another sub-task, this time that raises an exception
with pytest.raises(ValueError):
with progress.sub_task("Sub-task", total=28) as sub_task_id:
assert sub_task_id == 1
assert len(progress.tasks) == 1
assert progress.task_ids[0] == sub_task_id
assert progress.tasks[0].total == 28
raise ValueError("This is a test error")

# The sub-task should also be gone now
assert progress.tasks == []

#
# Test for 'utils.DownloadProgress.get_renderables'
#
def test_download_progress_renderables(self):
# Test the "summary" progress type
with ContainerProgress() as progress:
assert progress.tasks == []
progress.add_task("Task 1", progress_type="summary", total=42, completed=11)
assert len(progress.tasks) == 1

renderable = progress.get_renderable()
assert isinstance(renderable, rich.console.Group), type(renderable)

assert len(renderable.renderables) == 1
table = renderable.renderables[0]
assert isinstance(table, rich.table.Table)

assert isinstance(table.columns[0]._cells[0], str)
assert table.columns[0]._cells[0] == "[magenta]Task 1"

assert isinstance(table.columns[1]._cells[0], rich.progress_bar.ProgressBar)
assert table.columns[1]._cells[0].completed == 11
assert table.columns[1]._cells[0].total == 42

assert isinstance(table.columns[2]._cells[0], str)
assert table.columns[2]._cells[0] == "[progress.percentage] 26%"

assert isinstance(table.columns[3]._cells[0], str)
assert table.columns[3]._cells[0] == "•"

assert isinstance(table.columns[4]._cells[0], str)
assert table.columns[4]._cells[0] == "[green]11/42 tasks completed"


class ContainerTest(unittest.TestCase):
Expand Down
33 changes: 33 additions & 0 deletions tests/pipelines/download/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,49 @@
from unittest import mock

import pytest
import rich.progress_bar
import rich.table
import rich.text

from nf_core.pipelines.download import DownloadWorkflow
from nf_core.pipelines.download.docker import (
DockerError,
DockerFetcher,
DockerProgress,
)

from ...utils import with_temporary_folder


#
# Test the DockerProgress subclass
#
class DockerProgressTest(unittest.TestCase):
@pytest.fixture(autouse=True)
def use_caplog(self, caplog):
self._caplog = caplog

def test_docker_progress_pull(self):
with DockerProgress() as progress:
assert progress.tasks == []
progress.add_task(
"Task 1", progress_type="docker", total=2, completed=1, current_log="example log", status="Pulling"
)
assert len(progress.tasks) == 1

renderable = progress.get_renderable()
assert isinstance(renderable, rich.console.Group), type(renderable)

assert len(renderable.renderables) == 1
table = renderable.renderables[0]
assert isinstance(table, rich.table.Table)

assert isinstance(table.columns[0]._cells[0], str)
assert table.columns[0]._cells[0] == "[magenta]Task 1"
assert isinstance(table.columns[2]._cells[0], str)
assert table.columns[2]._cells[0] == "([blue]Pulling)"


class DockerTest(unittest.TestCase):
@pytest.fixture(autouse=True)
def use_caplog(self, caplog):
Expand Down
Loading