Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikDanielsson committed Aug 2, 2022
1 parent f2bd50b commit dd2032d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
5 changes: 4 additions & 1 deletion nf_core/modules/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nf_core/modules/lint/meta_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 23 additions & 5 deletions tests/modules/lint.py
Original file line number Diff line number Diff line change
@@ -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"""
Expand All @@ -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):
Expand All @@ -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
2 changes: 2 additions & 0 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit dd2032d

Please sign in to comment.