From 7e40458a471e62f158d3a9bd8b44a047b5924d37 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Mon, 27 Mar 2023 14:19:42 +0200 Subject: [PATCH 01/11] Test subworkflow yml dumper --- tests/subworkflows/create_test_yml.py | 24 ++++++++++++++++++++++++ tests/test_subworkflows.py | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 tests/subworkflows/create_test_yml.py diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py new file mode 100644 index 0000000000..1654117bb6 --- /dev/null +++ b/tests/subworkflows/create_test_yml.py @@ -0,0 +1,24 @@ +import os +from unittest import mock + +import pytest + +import nf_core.subworkflows + +from ..utils import with_temporary_folder + + +@with_temporary_folder +def test_subworkflows_custom_yml_dumper(self, out_dir): + """Try to create a yml file with the custom yml dumper""" + yml_output_path = os.path.join(out_dir, "test.yml") + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow="test/tool", + directory=self.pipeline_dir, + test_yml_output_path=yml_output_path, + no_prompts=True, + ) + meta_builder.test_yml_output_path = yml_output_path + meta_builder.tests = [{"testname": "myname"}] + meta_builder.print_test_yml() + assert os.path.isfile(yml_output_path) diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index c5d768ab10..b11af31325 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -93,6 +93,9 @@ def tearDown(self): test_subworkflows_create_nfcore_modules, test_subworkflows_create_succeed, ) + from .subworkflows.create_test_yml import ( + test_subworkflows_custom_yml_dumper, + ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, test_subworkflows_info_local, From 488b25e1498f72675dec264dbb15449be0e00de9 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Mon, 27 Mar 2023 14:34:21 +0200 Subject: [PATCH 02/11] Test create_test_file_dict --- tests/subworkflows/create_test_yml.py | 16 ++++++++++++++++ tests/test_subworkflows.py | 1 + 2 files changed, 17 insertions(+) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index 1654117bb6..ff4f03c1fd 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -22,3 +22,19 @@ def test_subworkflows_custom_yml_dumper(self, out_dir): meta_builder.tests = [{"testname": "myname"}] meta_builder.print_test_yml() assert os.path.isfile(yml_output_path) + + +@with_temporary_folder +def test_subworkflows_test_file_dict(self, test_file_dir): + """Create dict of test files and create md5 sums""" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow="test/tool", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + fh.write("this line is just for testing") + test_files = meta_builder.create_test_file_dict(test_file_dir) + assert len(test_files) == 1 + assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index b11af31325..50f674f29e 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -95,6 +95,7 @@ def tearDown(self): ) from .subworkflows.create_test_yml import ( test_subworkflows_custom_yml_dumper, + test_subworkflows_test_file_dict, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From c404c8717d98e44a703575a754a298b1e09d35da Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Mon, 27 Mar 2023 15:06:17 +0200 Subject: [PATCH 03/11] Test get_md5_sums --- nf_core/subworkflows/test_yml_builder.py | 4 ++-- tests/subworkflows/create_test_yml.py | 19 +++++++++++++++++++ tests/test_subworkflows.py | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/nf_core/subworkflows/test_yml_builder.py b/nf_core/subworkflows/test_yml_builder.py index 39877ca241..384561bf68 100644 --- a/nf_core/subworkflows/test_yml_builder.py +++ b/nf_core/subworkflows/test_yml_builder.py @@ -195,7 +195,7 @@ def build_single_test(self, entry_point): ).strip() ep_test["tags"] = [t.strip() for t in prompt_tags.split(",")] - ep_test["files"] = self.get_md5_sums(entry_point, ep_test["command"]) + ep_test["files"] = self.get_md5_sums(ep_test["command"]) return ep_test @@ -272,7 +272,7 @@ def create_test_file_dict(self, results_dir, is_repeat=False): return test_files - def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repeat=None): + def get_md5_sums(self, command, results_dir=None, results_dir_repeat=None): """ Recursively go through directories and subdirectories and generate tuples of (, ) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index ff4f03c1fd..33ad59d655 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -38,3 +38,22 @@ def test_subworkflows_test_file_dict(self, test_file_dir): test_files = meta_builder.create_test_file_dict(test_file_dir) assert len(test_files) == 1 assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" + + +@with_temporary_folder +def test_subworkflows_create_test_yml_get_md5(self, test_file_dir): + """Get md5 sums from a dummy output""" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow="test/tool", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + fh.write("this line is just for testing") + test_files = meta_builder.get_md5_sums( + command="dummy", + results_dir=test_file_dir, + results_dir_repeat=test_file_dir, + ) + assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index 50f674f29e..f888c982de 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -96,6 +96,7 @@ def tearDown(self): from .subworkflows.create_test_yml import ( test_subworkflows_custom_yml_dumper, test_subworkflows_test_file_dict, + test_subworkflows_create_test_yml_get_md5, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From 4db16799abdddccf61ca058fb4bd68d88369dccb Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 13:29:09 +0200 Subject: [PATCH 04/11] Test scrape_workflow_entry_points --- nf_core/subworkflow-template/tests/main.nf | 2 +- nf_core/subworkflows/test_yml_builder.py | 2 +- tests/subworkflows/create_test_yml.py | 16 ++++++++++++++++ tests/test_subworkflows.py | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/nf_core/subworkflow-template/tests/main.nf b/nf_core/subworkflow-template/tests/main.nf index 2bf63da2f3..f8c9b10dcb 100644 --- a/nf_core/subworkflow-template/tests/main.nf +++ b/nf_core/subworkflow-template/tests/main.nf @@ -4,7 +4,7 @@ nextflow.enable.dsl = 2 include { {{ subworkflow_name|upper }} } from '../../../../subworkflows/{{ org }}/{{ subworkflow_dir }}/main.nf' -workflow test_{{ subworkflow_name }} { +workflow test_{{ component_name_underscore }} { {% if has_meta %} input = [ [ id:'test' ], // meta map diff --git a/nf_core/subworkflows/test_yml_builder.py b/nf_core/subworkflows/test_yml_builder.py index 384561bf68..2ad50d4e25 100644 --- a/nf_core/subworkflows/test_yml_builder.py +++ b/nf_core/subworkflows/test_yml_builder.py @@ -139,7 +139,7 @@ def scrape_workflow_entry_points(self): if match: self.entry_points.append(match.group(1)) if len(self.entry_points) == 0: - raise UserWarning("No workflow entry points found in 'self.module_test_main'") + raise UserWarning(f"No workflow entry points found in '{self.subworkflow_test_main}'") def build_all_tests(self): """ diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index 33ad59d655..ac06a45e68 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -57,3 +57,19 @@ def test_subworkflows_create_test_yml_get_md5(self, test_file_dir): results_dir_repeat=test_file_dir, ) assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" + + +def test_subworkflows_create_test_yml_entry_points(self): + """Test extracting test entry points from a main.nf file""" + subworkflow = "test_subworkflow" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow=f"{subworkflow}/test", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + meta_builder.subworkflow_test_main = os.path.join( + self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" + ) + meta_builder.scrape_workflow_entry_points() + assert meta_builder.entry_points[0] == f"test_{subworkflow}" diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index f888c982de..663d51a474 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -97,6 +97,7 @@ def tearDown(self): test_subworkflows_custom_yml_dumper, test_subworkflows_test_file_dict, test_subworkflows_create_test_yml_get_md5, + test_subworkflows_create_test_yml_entry_points, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From e7bda6db3da0638e62baa5ab4d845d0bb60dac38 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 14:16:12 +0200 Subject: [PATCH 05/11] Test check_inputs --- tests/subworkflows/create_test_yml.py | 20 ++++++++++++++++++++ tests/test_subworkflows.py | 1 + 2 files changed, 21 insertions(+) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index ac06a45e68..a2f3bb321d 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -73,3 +73,23 @@ def test_subworkflows_create_test_yml_entry_points(self): ) meta_builder.scrape_workflow_entry_points() assert meta_builder.entry_points[0] == f"test_{subworkflow}" + + +def test_subworkflows_create_test_yml_check_inputs(self): + """Test the check_inputs() function - raise UserWarning because test.yml exists""" + cwd = os.getcwd() + os.chdir(self.nfcore_modules) + subworkflow = "test_subworkflow" + meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( + subworkflow=f"{subworkflow}", + directory=self.pipeline_dir, + test_yml_output_path="./", + no_prompts=True, + ) + meta_builder.subworkflow_test_main = os.path.join( + self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" + ) + with pytest.raises(UserWarning) as excinfo: + meta_builder.check_inputs() + os.chdir(cwd) + assert "Test YAML file already exists!" in str(excinfo.value) diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index 663d51a474..aa8be60863 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -98,6 +98,7 @@ def tearDown(self): test_subworkflows_test_file_dict, test_subworkflows_create_test_yml_get_md5, test_subworkflows_create_test_yml_entry_points, + test_subworkflows_create_test_yml_check_inputs, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From 36aab3837db4ec020245923d6239115891b3b742 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 14:30:39 +0200 Subject: [PATCH 06/11] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4797f020e0..21f41cef7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,10 @@ - Use `nfcore/gitpod:dev` container in the dev branch ([#2196](https://github.com/nf-core/tools/pull/2196)) - Replace requests_mock with responses in test mocks ([#2165](https://github.com/nf-core/tools/pull/2165)). +### Bug fixes, maintenance and tests + +- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) + ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] ### Template From a661087f0d1a5e1040071a3b9a9ec4adb1bbf13e Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Tue, 28 Mar 2023 16:16:32 +0200 Subject: [PATCH 07/11] Fix linting --- CHANGELOG.md | 2 +- README.md | 4 ++-- tests/test_subworkflows.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f41cef7e..fc18f9ccee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ ### Bug fixes, maintenance and tests -- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) +- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] diff --git a/README.md b/README.md index 63bf235bc7..2fe09e80d2 100644 --- a/README.md +++ b/README.md @@ -612,7 +612,7 @@ The graphical interface is oganzised in groups and within the groups the single Now you can start to change the parameter itself. The `ID` of a new parameter should be defined in small letters without whitespaces. The description is a short free text explanation about the parameter, that appears if you run your pipeline with the `--help` flag. By clicking on the dictionary icon you can add a longer explanation for the parameter page of your pipeline. Usually, they contain a small paragraph about the parameter settings or a used datasource, like databases or references. If you want to specify some conditions for your parameter, like the file extension, you can use the nut icon to open the settings. This menu depends on the `type` you assigned to your parameter. For integers you can define a min and max value, and for strings the file extension can be specified. -The `type` field is one of the most important points in your pipeline schema, since it defines the datatype of your input and how it will be interpreted. This allows extensive testing prior to starting the pipeline. +The `type` field is one of the most important points in your pipeline schema, since it defines the datatype of your input and how it will be interpreted. This allows extensive testing prior to starting the pipeline. The basic datatypes for a pipeline schema are: @@ -621,7 +621,7 @@ The basic datatypes for a pipeline schema are: - `integer` - `boolean` -For the `string` type you have three different options in the settings (nut icon): `enumerated values`, `pattern` and `format`. The first option, `enumerated values`, allows you to specify a list of specific input values. The list has to be separated with a pipe. The `pattern` and `format` settings can depend on each other. The `format` has to be either a directory or a file path. Depending on the `format` setting selected, specifying the `pattern` setting can be the most efficient and time saving option, especially for `file paths`. The `number` and `integer` types share the same settings. Similarly to `string`, there is an `enumerated values` option with the possibility of specifying a `min` and `max` value. For the `boolean` there is no further settings and the default value is usually `false`. The `boolean` value can be switched to `true` by adding the flag to the command. This parameter type is often used to skip specific sections of a pipeline. +For the `string` type you have three different options in the settings (nut icon): `enumerated values`, `pattern` and `format`. The first option, `enumerated values`, allows you to specify a list of specific input values. The list has to be separated with a pipe. The `pattern` and `format` settings can depend on each other. The `format` has to be either a directory or a file path. Depending on the `format` setting selected, specifying the `pattern` setting can be the most efficient and time saving option, especially for `file paths`. The `number` and `integer` types share the same settings. Similarly to `string`, there is an `enumerated values` option with the possibility of specifying a `min` and `max` value. For the `boolean` there is no further settings and the default value is usually `false`. The `boolean` value can be switched to `true` by adding the flag to the command. This parameter type is often used to skip specific sections of a pipeline. After filling the schema, click on the `Finished` button in the top right corner, this will automatically update your `nextflow_schema.json`. If this is not working, the schema can be copied from the graphical interface and pasted in your `nextflow_schema.json` file. diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index aa8be60863..19a090f7f0 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -94,11 +94,11 @@ def tearDown(self): test_subworkflows_create_succeed, ) from .subworkflows.create_test_yml import ( + test_subworkflows_create_test_yml_check_inputs, + test_subworkflows_create_test_yml_entry_points, + test_subworkflows_create_test_yml_get_md5, test_subworkflows_custom_yml_dumper, test_subworkflows_test_file_dict, - test_subworkflows_create_test_yml_get_md5, - test_subworkflows_create_test_yml_entry_points, - test_subworkflows_create_test_yml_check_inputs, ) from .subworkflows.info import ( test_subworkflows_info_in_modules_repo, From 41837df4b7ebb45e83bd6dd005405fe7dd36a49a Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 10:19:59 +0200 Subject: [PATCH 08/11] =?UTF-8?q?Switch=20from=20`os.path`=C2=A0to=20`Path?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Hörtenhuber --- tests/subworkflows/create_test_yml.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index a2f3bb321d..ed5715832f 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -1,6 +1,6 @@ import os from unittest import mock - +from pathlib import Path import pytest import nf_core.subworkflows @@ -11,7 +11,7 @@ @with_temporary_folder def test_subworkflows_custom_yml_dumper(self, out_dir): """Try to create a yml file with the custom yml dumper""" - yml_output_path = os.path.join(out_dir, "test.yml") + yml_output_path = Path(out_dir, "test.yml") meta_builder = nf_core.subworkflows.SubworkflowTestYmlBuilder( subworkflow="test/tool", directory=self.pipeline_dir, @@ -21,7 +21,7 @@ def test_subworkflows_custom_yml_dumper(self, out_dir): meta_builder.test_yml_output_path = yml_output_path meta_builder.tests = [{"testname": "myname"}] meta_builder.print_test_yml() - assert os.path.isfile(yml_output_path) + assert Path(yml_output_path).is_file() @with_temporary_folder @@ -33,7 +33,7 @@ def test_subworkflows_test_file_dict(self, test_file_dir): test_yml_output_path="./", no_prompts=True, ) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.create_test_file_dict(test_file_dir) assert len(test_files) == 1 @@ -68,7 +68,7 @@ def test_subworkflows_create_test_yml_entry_points(self): test_yml_output_path="./", no_prompts=True, ) - meta_builder.subworkflow_test_main = os.path.join( + meta_builder.subworkflow_test_main = Path( self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" ) meta_builder.scrape_workflow_entry_points() @@ -86,7 +86,7 @@ def test_subworkflows_create_test_yml_check_inputs(self): test_yml_output_path="./", no_prompts=True, ) - meta_builder.subworkflow_test_main = os.path.join( + meta_builder.subworkflow_test_main = Path( self.nfcore_modules, "tests", "subworkflows", "nf-core", subworkflow, "main.nf" ) with pytest.raises(UserWarning) as excinfo: From ef4738b26d3d79516cfa6eab823bdd59f076d40a Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 10:23:06 +0200 Subject: [PATCH 09/11] Switch from `os.path` to `Path` for modules too --- tests/modules/create_test_yml.py | 12 ++++++------ tests/subworkflows/create_test_yml.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/modules/create_test_yml.py b/tests/modules/create_test_yml.py index d444ff841a..950737062b 100644 --- a/tests/modules/create_test_yml.py +++ b/tests/modules/create_test_yml.py @@ -11,19 +11,19 @@ @with_temporary_folder def test_modules_custom_yml_dumper(self, out_dir): """Try to create a yml file with the custom yml dumper""" - yml_output_path = os.path.join(out_dir, "test.yml") + yml_output_path = Path(out_dir, "test.yml") meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True) meta_builder.test_yml_output_path = yml_output_path meta_builder.tests = [{"testname": "myname"}] meta_builder.print_test_yml() - assert os.path.isfile(yml_output_path) + assert Path(yml_output_path).is_file() @with_temporary_folder def test_modules_test_file_dict(self, test_file_dir): """Create dict of test files and create md5 sums""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.create_test_file_dict(test_file_dir) assert len(test_files) == 1 @@ -34,7 +34,7 @@ def test_modules_test_file_dict(self, test_file_dir): def test_modules_create_test_yml_get_md5(self, test_file_dir): """Get md5 sums from a dummy output""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("test/tool", self.pipeline_dir, False, "./", False, True) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.get_md5_sums(command="dummy", results_dir=test_file_dir, results_dir_repeat=test_file_dir) assert test_files[0]["md5sum"] == "2191e06b28b5ba82378bcc0672d01786" @@ -43,7 +43,7 @@ def test_modules_create_test_yml_get_md5(self, test_file_dir): def test_modules_create_test_yml_entry_points(self): """Test extracting test entry points from a main.nf file""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", self.pipeline_dir, False, "./", False, True) - meta_builder.module_test_main = os.path.join( + meta_builder.module_test_main = Path( self.nfcore_modules, "tests", "modules", "nf-core", "bpipe", "test", "main.nf" ) meta_builder.scrape_workflow_entry_points() @@ -55,7 +55,7 @@ def test_modules_create_test_yml_check_inputs(self): cwd = os.getcwd() os.chdir(self.nfcore_modules) meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", ".", False, "./", False, True) - meta_builder.module_test_main = os.path.join(self.nfcore_modules, "tests", "modules", "bpipe", "test", "main.nf") + meta_builder.module_test_main = Path(self.nfcore_modules, "tests", "modules", "bpipe", "test", "main.nf") with pytest.raises(UserWarning) as excinfo: meta_builder.check_inputs() os.chdir(cwd) diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index ed5715832f..a195f74d60 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -49,7 +49,7 @@ def test_subworkflows_create_test_yml_get_md5(self, test_file_dir): test_yml_output_path="./", no_prompts=True, ) - with open(os.path.join(test_file_dir, "test_file.txt"), "w") as fh: + with open(Path(test_file_dir, "test_file.txt"), "w") as fh: fh.write("this line is just for testing") test_files = meta_builder.get_md5_sums( command="dummy", From 8d81588af485759eda1549e62fc55b1e43090027 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 10:37:06 +0200 Subject: [PATCH 10/11] Lint code (isort, black) --- tests/modules/create_test_yml.py | 4 +--- tests/subworkflows/create_test_yml.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/modules/create_test_yml.py b/tests/modules/create_test_yml.py index 950737062b..243378af78 100644 --- a/tests/modules/create_test_yml.py +++ b/tests/modules/create_test_yml.py @@ -43,9 +43,7 @@ def test_modules_create_test_yml_get_md5(self, test_file_dir): def test_modules_create_test_yml_entry_points(self): """Test extracting test entry points from a main.nf file""" meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", self.pipeline_dir, False, "./", False, True) - meta_builder.module_test_main = Path( - self.nfcore_modules, "tests", "modules", "nf-core", "bpipe", "test", "main.nf" - ) + meta_builder.module_test_main = Path(self.nfcore_modules, "tests", "modules", "nf-core", "bpipe", "test", "main.nf") meta_builder.scrape_workflow_entry_points() assert meta_builder.entry_points[0] == "test_bpipe_test" diff --git a/tests/subworkflows/create_test_yml.py b/tests/subworkflows/create_test_yml.py index a195f74d60..40384b420f 100644 --- a/tests/subworkflows/create_test_yml.py +++ b/tests/subworkflows/create_test_yml.py @@ -1,6 +1,7 @@ import os -from unittest import mock from pathlib import Path +from unittest import mock + import pytest import nf_core.subworkflows From 20f82c08d7f7a529f33cd0af36da3e4dd7621393 Mon Sep 17 00:00:00 2001 From: Adrien Coulier Date: Wed, 29 Mar 2023 12:04:10 +0200 Subject: [PATCH 11/11] Fix changelog [skip ci] --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc18f9ccee..bb12675044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Fixing problem when a module included in a subworkflow had a name change from TOOL to TOOL/SUBTOOL ([#2177](https://github.com/nf-core/tools/pull/2177)) - Fix `nf-core subworkflows test` not running subworkflow tests ([#2181](https://github.com/nf-core/tools/pull/2181)) +- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) ### General @@ -29,10 +30,6 @@ - Use `nfcore/gitpod:dev` container in the dev branch ([#2196](https://github.com/nf-core/tools/pull/2196)) - Replace requests_mock with responses in test mocks ([#2165](https://github.com/nf-core/tools/pull/2165)). -### Bug fixes, maintenance and tests - -- Add tests for `nf-core subworkflows create-test-yml` ([#2219](https://github.com/nf-core/tools/pull/2219)) - ## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19] ### Template