Skip to content

Commit

Permalink
apply suggestions by @mashehu
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Nov 25, 2024
1 parent 84cec26 commit 8b2bec4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions tests/modules/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_create_patch_no_change(self):
module_path = Path(self.pipeline_dir, "modules", REPO_NAME, BISMARK_ALIGN)

# Check that no patch file has been added to the directory
assert "bismark-align.diff" not in set(os.listdir(module_path))
assert not (module_path / "bismark-align.diff").exists()

# Check the 'modules.json' contains no patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand All @@ -94,7 +94,7 @@ def test_create_patch_change(self):

patch_fn = f"{'-'.join(BISMARK_ALIGN.split('/'))}.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_create_patch_try_apply_successful(self):

patch_fn = f"{'-'.join(BISMARK_ALIGN.split('/'))}.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand All @@ -153,7 +153,7 @@ def test_create_patch_try_apply_successful(self):
update_obj.move_files_from_tmp_dir(BISMARK_ALIGN, install_dir, REPO_NAME, SUCCEED_SHA)

# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_create_patch_try_apply_failed(self):

patch_fn = f"{'-'.join(BISMARK_ALIGN.split('/'))}.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_create_patch_update_success(self):

patch_fn = f"{'-'.join(BISMARK_ALIGN.split('/'))}.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand All @@ -254,7 +254,7 @@ def test_create_patch_update_success(self):
assert update_obj.update(BISMARK_ALIGN)

# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_create_patch_update_fail(self):

patch_fn = f"{'-'.join(BISMARK_ALIGN.split('/'))}.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -349,7 +349,7 @@ def test_remove_patch(self):

# Check that a patch file with the correct name has been created
patch_fn = f"{'-'.join(BISMARK_ALIGN.split('/'))}.diff"
assert patch_fn in set(os.listdir(module_path))
assert (module_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the module
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand All @@ -361,7 +361,7 @@ def test_remove_patch(self):
mock_questionary.unsafe_ask.return_value = True
patch_obj.remove(BISMARK_ALIGN)
# Check that the diff file has been removed
assert patch_fn not in set(os.listdir(module_path))
assert not (module_path / patch_fn).exists()

# Check that the 'modules.json' entry has been removed
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down
20 changes: 10 additions & 10 deletions tests/subworkflows/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_create_patch_no_change(self):
subworkflow_path = Path(self.pipeline_dir, "subworkflows", GITLAB_REPO, "bam_sort_stats_samtools")

# Check that no patch file has been added to the directory
assert "bam_sort_stats_samtools.diff" not in set(os.listdir(subworkflow_path))
assert not (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

def test_create_patch_change(self):
"""Test creating a patch when there is no change to the subworkflow"""
Expand All @@ -79,7 +79,7 @@ def test_create_patch_change(self):
subworkflow_path = Path(self.pipeline_dir, "subworkflows", GITLAB_REPO, "bam_sort_stats_samtools")

# Check that a patch file with the correct name has been created
assert "bam_sort_stats_samtools.diff" in set(os.listdir(subworkflow_path))
assert (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

# Check that the correct lines are in the patch file
with open(subworkflow_path / "bam_sort_stats_samtools.diff") as fh:
Expand All @@ -101,7 +101,7 @@ def test_create_patch_try_apply_successful(self):
patch_obj.patch("bam_sort_stats_samtools")

# Check that a patch file with the correct name has been created
assert "bam_sort_stats_samtools.diff" in set(os.listdir(subworkflow_path))
assert (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

update_obj = nf_core.subworkflows.SubworkflowUpdate(
self.pipeline_dir, sha=OLD_SHA, remote_url=GITLAB_URL, branch=GITLAB_SUBWORKFLOWS_BRANCH
Expand All @@ -125,7 +125,7 @@ def test_create_patch_try_apply_successful(self):
update_obj.move_files_from_tmp_dir("bam_sort_stats_samtools", install_dir, GITLAB_REPO, OLD_SHA)

# Check that a patch file with the correct name has been created
assert "bam_sort_stats_samtools.diff" in set(os.listdir(subworkflow_path))
assert (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

# Check that the correct lines are in the patch file
with open(subworkflow_path / "bam_sort_stats_samtools.diff") as fh:
Expand All @@ -152,7 +152,7 @@ def test_create_patch_try_apply_failed(self):
patch_obj.patch("bam_sort_stats_samtools")

# Check that a patch file with the correct name has been created
assert "bam_sort_stats_samtools.diff" in set(os.listdir(subworkflow_path))
assert (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

update_obj = nf_core.subworkflows.SubworkflowUpdate(
self.pipeline_dir, remote_url=GITLAB_URL, branch=GITLAB_SUBWORKFLOWS_BRANCH
Expand Down Expand Up @@ -188,7 +188,7 @@ def test_create_patch_update_success(self):

patch_fn = "bam_sort_stats_samtools.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(swf_path))
assert (swf_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the subworkflow
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand All @@ -208,7 +208,7 @@ def test_create_patch_update_success(self):
assert update_obj.update("bam_sort_stats_samtools")

# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(swf_path))
assert (swf_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the subworkflow
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_create_patch_update_fail(self):

patch_fn = "bam_sort_stats_samtools.diff"
# Check that a patch file with the correct name has been created
assert patch_fn in set(os.listdir(swf_path))
assert (swf_path / patch_fn).exists()

# Check the 'modules.json' contains a patch file for the subworkflow
modules_json_obj = nf_core.modules.modules_json.ModulesJson(self.pipeline_dir)
Expand Down Expand Up @@ -298,10 +298,10 @@ def test_remove_patch(self):
subworkflow_path = Path(self.pipeline_dir, "subworkflows", GITLAB_REPO, "bam_sort_stats_samtools")

# Check that a patch file with the correct name has been created
assert "bam_sort_stats_samtools.diff" in set(os.listdir(subworkflow_path))
assert (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

with mock.patch.object(nf_core.components.patch.questionary, "confirm") as mock_questionary:
mock_questionary.unsafe_ask.return_value = True
patch_obj.remove("bam_sort_stats_samtools")
# Check that the diff file has been removed
assert "bam_sort_stats_samtools.diff" not in set(os.listdir(subworkflow_path))
assert not (subworkflow_path / "bam_sort_stats_samtools.diff").exists()

0 comments on commit 8b2bec4

Please sign in to comment.