Skip to content

Commit

Permalink
Fix error messages in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasZepper committed May 3, 2024
1 parent 4b0fe7b commit 5e35492
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
15 changes: 10 additions & 5 deletions nf_core/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,17 +1736,22 @@ def __add_additional_tags(self) -> None:
if self.repo.is_valid_object(anchor) and not self.repo.is_valid_object(tag):
try:
self.repo.create_tag(
tag, ref=anchor, message=f"Synonynmous tag to {anchor}; added by 'nf-core download'."
tag, ref=anchor, message=f"Synonynmous tag to {anchor}; added by `nf-core download`."
)
self.repo.create_head(tag, anchor) # should heads be created as well?
except (GitCommandError, InvalidGitRepositoryError) as e:
log.error(f"[red]Additional tag(s) could not be applied:[/]\n{e}\n")
else:
log.error(
f"[red]Adding the additional tag '{tag}' to '{anchor}' failed.[/]\n Mind that '{anchor}' must be a valid git reference that resolves to a commit, while '{tag}' must not exist hitherto."
)
if not self.repo.is_valid_object(anchor):
log.error(
f"[red]Adding tag '{tag}' to '{anchor}' failed.[/]\n Mind that '{anchor}' must be a valid git reference that resolves to a commit."
)
if self.repo.is_valid_object(tag):
log.error(
f"[red]Adding tag '{tag}' to '{anchor}' failed.[/]\n Mind that '{tag}' must not exist hitherto."
)
else:
log.error(f"[red]Could not apply invalid '--tag' specification[/]: '{additional_tag}'")
log.error(f"[red]Could not apply invalid `--tag` specification[/]: '{additional_tag}'")

def bare_clone(self, destination):
if self.repo:
Expand Down
37 changes: 20 additions & 17 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,23 @@ def test_download_workflow_for_platform(self, tmp_dir, _):
) # indirect definition via $container variable.

#
# Test adding custom tags to Seqera Platform download
# Brief test adding a single custom tag to Seqera Platform download
#
@mock.patch("nf_core.download.DownloadWorkflow.get_singularity_images")
@with_temporary_folder
def test_download_workflow_for_platform_with_one_custom_tag(self, _, tmp_dir):
download_obj = DownloadWorkflow(
pipeline="nf-core/rnaseq",
revision=("3.9"),
compress_type="none",
platform=True,
container_system=None,
additional_tags=("3.9=cool_revision",),
)
assert isinstance(download_obj.additional_tags, list) and len(download_obj.additional_tags) == 1

#
# Test adding custom tags to Seqera Platform download (full test)
#
@mock.patch("nf_core.download.DownloadWorkflow.get_singularity_images")
@with_temporary_folder
Expand Down Expand Up @@ -707,21 +723,8 @@ def test_download_workflow_for_platform_with_custom_tags(self, _, tmp_dir):
assert all(
log in self.logged_messages
for log in {
"[red]Could not apply invalid '-a' / '--additional-tag' specification[/]: '3.9=invalid tag'",
"[red]Adding the additional tag 'not_included' to '3.14.0' failed.[/]\n Mind that '3.14.0' must be a valid git reference that resolves to a commit, while 'not_included' must not exist hitherto.",
"[red]Could not apply invalid '-a' / '--additional-tag' specification[/]: 'What is this?'",
"[red]Could not apply invalid `--tag` specification[/]: '3.9=invalid tag'",
"[red]Adding tag 'not_included' to '3.14.0' failed.[/]\n Mind that '3.14.0' must be a valid git reference that resolves to a commit.",
"[red]Could not apply invalid `--tag` specification[/]: 'What is this?'",
}
)

@mock.patch("nf_core.download.DownloadWorkflow.get_singularity_images")
@with_temporary_folder
def test_download_workflow_for_platform_with_one_custom_tag(self, _, tmp_dir):
download_obj = DownloadWorkflow(
pipeline="nf-core/rnaseq",
revision=("3.9"),
compress_type="none",
platform=True,
container_system=None,
additional_tags=("3.9=cool_revision",),
)
assert isinstance(download_obj.additional_tags, list) and len(download_obj.additional_tags) == 1

0 comments on commit 5e35492

Please sign in to comment.