Skip to content

Commit

Permalink
delete component from pytest_modules.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Nov 30, 2023
1 parent 80ad88d commit d03b7ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nf_core/components/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import jinja2
import questionary
import rich
import yaml
from packaging.version import parse as parse_version

import nf_core
import nf_core.utils
from nf_core.components.components_command import ComponentCommand
from nf_core.lint_utils import run_prettier_on_file

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -475,3 +477,12 @@ def _print_and_delete_pytest_files(self):
"You can find more information about nf-test [link=https://nf-co.re/docs/contributing/modules#migrating-from-pytest-to-nf-test]at the nf-core web[/link].\n"
f"Once done, make sure to delete the module pytest files to avoid linting errors: {pytest_dir}"
)
# Delete tags from pytest_modules.yml
modules_yml = Path(self.directory, "tests", "config", "pytest_modules.yml")
with open(modules_yml, "r") as fh:
yml_file = yaml.safe_load(fh)
yml_key = self.component_dir if self.component_type == "modules" else f"subworkflows/{self.component_dir}"
del yml_file[yml_key]
with open(modules_yml, "w") as fh:
yaml.dump(yml_file, fh)
run_prettier_on_file(modules_yml)
11 changes: 11 additions & 0 deletions tests/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import requests_cache
import responses
import yaml
from git.repo import Repo

import nf_core.modules
Expand Down Expand Up @@ -105,6 +106,11 @@ def test_modules_migrate(self, mock_rich_ask):
# Check that pytest folder is deleted
assert not pytest_dir.is_dir()

# Check that pytest_modules.yml is updated
with open(Path(self.nfcore_modules, "tests", "config", "pytest_modules.yml")) as fh:
modules_yml = yaml.safe_load(fh)
assert "samtools/sort" not in modules_yml.keys()


@mock.patch("rich.prompt.Confirm.ask")
def test_modules_migrate_no_delete(self, mock_rich_ask):
Expand All @@ -123,3 +129,8 @@ def test_modules_migrate_no_delete(self, mock_rich_ask):

# Check that pytest folder is not deleted
assert pytest_dir.is_dir()

# Check that pytest_modules.yml is updated
with open(Path(self.nfcore_modules, "tests", "config", "pytest_modules.yml")) as fh:
modules_yml = yaml.safe_load(fh)
assert "samtools/sort" not in modules_yml.keys()
11 changes: 11 additions & 0 deletions tests/subworkflows/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest import mock

import pytest
import yaml
from git.repo import Repo

import nf_core.subworkflows
Expand Down Expand Up @@ -75,6 +76,11 @@ def test_subworkflows_migrate(self, mock_rich_ask):
# Check that pytest folder is deleted
assert not pytest_dir.is_dir()

# Check that pytest_modules.yml is updated
with open(Path(self.nfcore_modules, "tests", "config", "pytest_modules.yml")) as fh:
modules_yml = yaml.safe_load(fh)
assert "subworkflows/bam_stats_samtools" not in modules_yml.keys()


@mock.patch("rich.prompt.Confirm.ask")
def test_subworkflows_migrate_no_delete(self, mock_rich_ask):
Expand All @@ -95,3 +101,8 @@ def test_subworkflows_migrate_no_delete(self, mock_rich_ask):

# Check that pytest folder is not deleted
assert pytest_dir.is_dir()

# Check that pytest_modules.yml is updated
with open(Path(self.nfcore_modules, "tests", "config", "pytest_modules.yml")) as fh:
modules_yml = yaml.safe_load(fh)
assert "subworkflows/bam_stats_samtools" not in modules_yml.keys()

0 comments on commit d03b7ae

Please sign in to comment.