diff --git a/nf_core/lint.py b/nf_core/lint.py index 97b7f1f335..9f5d7ebacc 100644 --- a/nf_core/lint.py +++ b/nf_core/lint.py @@ -60,7 +60,6 @@ def check_files_exist (self): files_fail = [ 'LICENSE', 'README.md', - 'nextflow.config', 'Dockerfile', 'docs/README.md', 'nextflow.config' diff --git a/requirements.txt b/requirements.txt index e69de29bb2..dca9a90964 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +click diff --git a/tests/lint_examples/critical_example/LICENSE b/tests/lint_examples/critical_example/LICENSE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/lint_examples/failing_example/main.nf b/tests/lint_examples/failing_example/main.nf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/lint_examples/failing_example/nextflow.config b/tests/lint_examples/failing_example/nextflow.config new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_lint.py b/tests/test_lint.py new file mode 100644 index 0000000000..e822dbeb28 --- /dev/null +++ b/tests/test_lint.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +"""Some tests covering the linting code. +Provide example wokflow directory contents like: + + --tests + |--lint_examples + | |--missing_license + | | |... + | |--missing_config + | | |.... + | |... + |--test_lint.py +""" +import os +import unittest +import nf_core.lint +from nose.tools import raises + +def pf(wd, path): + return os.path.join(wd, path) + +WD = os.path.dirname(__file__) +PATH_CRITICAL_EXAMPLE = pf(WD, 'lint_examples/critical_example') +PATH_FAILING_EXAMPLE = pf(WD, 'lint_examples/failing_example') + +class TestLint(unittest.TestCase): + """Class for lint tests""" + + @raises(AssertionError) + def test_critical_example(self): + """Tests for missing nextflow config and main.nf files""" + lint_obj = nf_core.lint.PipelineLint(PATH_CRITICAL_EXAMPLE) + lint_obj.lint_pipeline() + + def test_failing_example(self): + """Tests for missing files like Dockerfile or LICENSE""" + lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE) + lint_obj.lint_pipeline() + assert len(lint_obj.failed) == 4, "Expected 6 files missing, but found %r" % len(lint_obj.failed) + assert len(lint_obj.passed) == 2, "Expected 6 files missing, but found %r" % len(lint_obj.passed) \ No newline at end of file