From 7b9ca7cc0e56ac4eeacbdac7819792b4978d0b6a Mon Sep 17 00:00:00 2001 From: sven1103 Date: Wed, 14 Feb 2018 21:03:25 +0100 Subject: [PATCH 1/3] Remove redundant entry for nextflow.config --- nf_core/lint.py | 1 - 1 file changed, 1 deletion(-) 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' From f2e9533d62596ff341361816c3a8b7fc45d86f89 Mon Sep 17 00:00:00 2001 From: sven1103 Date: Wed, 14 Feb 2018 21:04:22 +0100 Subject: [PATCH 2/3] Add click pkg as requirement --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index e69de29bb2..dca9a90964 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +click From 860a66cbddde7bca49120a2068cdcaacf55162e5 Mon Sep 17 00:00:00 2001 From: sven1103 Date: Wed, 14 Feb 2018 21:04:34 +0100 Subject: [PATCH 3/3] Start implementing unittests --- tests/lint_examples/critical_example/LICENSE | 0 tests/lint_examples/failing_example/main.nf | 0 .../failing_example/nextflow.config | 0 tests/test_lint.py | 40 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 tests/lint_examples/critical_example/LICENSE create mode 100644 tests/lint_examples/failing_example/main.nf create mode 100644 tests/lint_examples/failing_example/nextflow.config create mode 100644 tests/test_lint.py 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