From c423a4dece1c0a5dbf6b92eee1294030a39d1df7 Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Wed, 6 Nov 2024 12:58:33 +0100 Subject: [PATCH] migrate test --- .../invoke/test_invoke_subprocess.py | 38 ++++++++++++++++++ tests/unit/workflow/__init__.py | 0 tests/unit/workflow/test_snakemake_invoke.py | 39 ------------------- 3 files changed, 38 insertions(+), 39 deletions(-) delete mode 100644 tests/unit/workflow/__init__.py delete mode 100644 tests/unit/workflow/test_snakemake_invoke.py diff --git a/tests/unit/snakemake_invoke/invoke/test_invoke_subprocess.py b/tests/unit/snakemake_invoke/invoke/test_invoke_subprocess.py index c230ef2..709b620 100644 --- a/tests/unit/snakemake_invoke/invoke/test_invoke_subprocess.py +++ b/tests/unit/snakemake_invoke/invoke/test_invoke_subprocess.py @@ -1,7 +1,25 @@ import pytest +import sys +from pathlib import Path +from snakemake_invoke.config import SnakemakeInvokeConfig from snakemake_invoke.invoke.invoke_subprocess import InvokeSubprocess +@pytest.fixture() +def config_snakefile_path() -> Path: + return Path("/tmp/workflow/Snakefile") + + +@pytest.fixture +def config(config_snakefile_path): + return SnakemakeInvokeConfig(snakefile_path=config_snakefile_path) + + +@pytest.fixture +def invoke(config): + return InvokeSubprocess(config=config) + + @pytest.mark.parametrize( "input_args,expected", [ @@ -16,3 +34,23 @@ def test_args_to_shell_command(input_args, expected): result = InvokeSubprocess._args_to_shell_command(input_args) assert result == expected + + +def test_get_base_command(invoke) -> None: + base_command = invoke.get_base_command( + extra_args=["--keep-going"], + work_dir=Path("/tmp/work"), + ) + assert base_command == [ + sys.executable, + "-m", + "snakemake", + "-d", + "/tmp/work", + "--cores", + "1", + "--snakefile", + "/tmp/workflow/Snakefile", + "--rerun-incomplete", + "--keep-going", + ] diff --git a/tests/unit/workflow/__init__.py b/tests/unit/workflow/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/workflow/test_snakemake_invoke.py b/tests/unit/workflow/test_snakemake_invoke.py deleted file mode 100644 index f4ed6d4..0000000 --- a/tests/unit/workflow/test_snakemake_invoke.py +++ /dev/null @@ -1,39 +0,0 @@ -from __future__ import annotations - -from pathlib import Path - -import pytest -import sys -from pytest_mock import MockerFixture - -from snakemake_invoke.snakemake_invoke import SnakemakeInvoke - - -@pytest.fixture -def default_invoke() -> SnakemakeInvoke: - return SnakemakeInvoke() - - -def test_get_base_command(mocker: MockerFixture, default_invoke: SnakemakeInvoke) -> None: - mocker.patch.object(SnakemakeInvoke, "snakefile_path", "/tmp/workflow/Snakefile") - base_command = default_invoke.get_base_command( - extra_args=["--keep-going"], - work_dir=Path("/tmp/work"), - ) - assert base_command == [ - sys.executable, - "-m", - "snakemake", - "-d", - "/tmp/work", - "--cores", - "1", - "--snakefile", - "/tmp/workflow/Snakefile", - "--rerun-incomplete", - "--keep-going", - ] - - -if __name__ == "__main__": - pytest.main()