From dd2032d584e6b909812a36828531b4ce2f084035 Mon Sep 17 00:00:00 2001 From: Erik Danielsson Date: Tue, 2 Aug 2022 16:41:14 +0200 Subject: [PATCH] Fix failing tests --- nf_core/modules/lint/__init__.py | 5 ++++- nf_core/modules/lint/meta_yml.py | 2 +- tests/modules/lint.py | 28 +++++++++++++++++++++++----- tests/test_modules.py | 2 ++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index 43d19419f3..e0e4374994 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -96,9 +96,12 @@ def __init__(self, dir, fail_warned=False, remote_url=None, branch=None, no_pull else: raise LookupError(f"No modules from {self.modules_repo.remote_url} installed in pipeline.") else: + module_dir = Path(self.dir, "modules") self.all_remote_modules = [ - NFCoreModule(module_dir / m, self.repo_type, Path(self.dir)) for m in self.module_names["modules"] + NFCoreModule(m, None, module_dir / m, self.repo_type, Path(self.dir)) + for m in self.module_names["modules"] ] + self.all_local_modules = [] self.lint_config = None self.modules_json = None diff --git a/nf_core/modules/lint/meta_yml.py b/nf_core/modules/lint/meta_yml.py index 42f5ac21a1..146796fde2 100644 --- a/nf_core/modules/lint/meta_yml.py +++ b/nf_core/modules/lint/meta_yml.py @@ -28,7 +28,7 @@ def meta_yml(module_lint_object, module): if module.is_patched: lines = ModulesDiffer.try_apply_patch( module.module_name, - "nf-core/modules", + module_lint_object.modules_repo.fullname, module.patch_path, Path(module.module_dir).relative_to(module.base_dir), reverse=True, diff --git a/tests/modules/lint.py b/tests/modules/lint.py index 0f60377d5e..64b5f2ff0f 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -1,5 +1,9 @@ +import pytest + import nf_core.modules +from ..utils import GITLAB_URL + def test_modules_lint_trimgalore(self): """Test linting the TrimGalore! module""" @@ -16,11 +20,8 @@ def test_modules_lint_empty(self): self.mods_remove.remove("fastqc") self.mods_remove.remove("multiqc") self.mods_remove.remove("custom/dumpsoftwareversions") - module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir) - module_lint.lint(print_results=False, all_modules=True) - assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}" - assert len(module_lint.passed) == 0 - assert len(module_lint.warned) == 0 + with pytest.raises(LookupError): + nf_core.modules.ModuleLint(dir=self.pipeline_dir) def test_modules_lint_new_modules(self): @@ -30,3 +31,20 @@ def test_modules_lint_new_modules(self): assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}" assert len(module_lint.passed) > 0 assert len(module_lint.warned) >= 0 + + +def test_modules_lint_no_gitlab(self): + """Test linting a pipeline with no modules installed""" + with pytest.raises(LookupError): + nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) + + +def test_modules_lint_gitlab_modules(self): + """Lint modules from a different remote""" + self.mods_install_gitlab.install("fastqc") + self.mods_install_gitlab.install("multiqc") + module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) + module_lint.lint(print_results=False, all_modules=True) + assert len(module_lint.failed) == 0 + assert len(module_lint.passed) > 0 + assert len(module_lint.warned) >= 0 diff --git a/tests/test_modules.py b/tests/test_modules.py index beb6c54abf..c3a9abfbf8 100644 --- a/tests/test_modules.py +++ b/tests/test_modules.py @@ -110,7 +110,9 @@ def test_modulesrepo_class(self): ) from .modules.lint import ( test_modules_lint_empty, + test_modules_lint_gitlab_modules, test_modules_lint_new_modules, + test_modules_lint_no_gitlab, test_modules_lint_trimgalore, ) from .modules.list import (