From 8b2bec4933fe41645a3fe9a5bd7db32d030a5237 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 25 Nov 2024 15:39:55 +0100 Subject: [PATCH] apply suggestions by @mashehu --- tests/modules/test_patch.py | 20 ++++++++++---------- tests/subworkflows/test_patch.py | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/modules/test_patch.py b/tests/modules/test_patch.py index df24ce819b..f608278618 100644 --- a/tests/modules/test_patch.py +++ b/tests/modules/test_patch.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/tests/subworkflows/test_patch.py b/tests/subworkflows/test_patch.py index 3df575c3de..5bb6a6798e 100644 --- a/tests/subworkflows/test_patch.py +++ b/tests/subworkflows/test_patch.py @@ -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""" @@ -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: @@ -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 @@ -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: @@ -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 @@ -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) @@ -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) @@ -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) @@ -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()