From 893a55291607f81958dd4044837dd254de49e6ec Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Thu, 6 Jul 2023 13:48:13 -0500 Subject: [PATCH] Add tests. --- .gitignore | 4 +++- tests/conftest.py | 7 +++++++ tests/test_main.py | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index dd4d32ae..714ef89e 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,9 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST - +pip-* +*pytest* +tmp* # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. diff --git a/tests/conftest.py b/tests/conftest.py index 9015bd95..19e9e851 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,6 +32,13 @@ def zarr_tmp(tmp_path_factory): return tmp_file +@pytest.fixture(scope="session") +def zarr_tmp2(tmp_path_factory): + """Make a temp file for the output MDIO.""" + tmp_file = tmp_path_factory.mktemp(r"mdio2") + return tmp_file + + @pytest.fixture(scope="session") def segy_export_ibm_tmp(tmp_path_factory): """Make a temp file for the round-trip IBM SEG-Y.""" diff --git a/tests/test_main.py b/tests/test_main.py index ac91dfe5..c2e88b3e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -15,6 +15,7 @@ def runner() -> CliRunner: return CliRunner() +@pytest.mark.dependency() def test_main_succeeds(runner: CliRunner, segy_input: str, zarr_tmp: Path) -> None: """It exits with a status code of zero.""" cli_args = ["segy", "import"] @@ -27,6 +28,28 @@ def test_main_succeeds(runner: CliRunner, segy_input: str, zarr_tmp: Path) -> No assert result.exit_code == 0 +@pytest.mark.dependency(depends=["test_main_succeeds"]) +def test_main_info_succeeds(runner: CliRunner, zarr_tmp: Path) -> None: + """It exits with a status code of zero.""" + cli_args = ["utility", "info"] + cli_args.extend(["-i", str(zarr_tmp)]) + + result = runner.invoke(__main__.main, args=cli_args) + assert result.exit_code == 0 + + +@pytest.mark.dependency(depends=["test_main_succeeds"]) +def test_main_copy_succeeds(runner: CliRunner, zarr_tmp: Path, zarr_tmp2: Path) -> None: + """It exits with a status code of zero.""" + cli_args = ["utility", "copy"] + cli_args.extend(["-i", str(zarr_tmp)]) + cli_args.extend(["-o", str(zarr_tmp2)]) + + result = runner.invoke(__main__.main, args=cli_args) + print(f"copy returns {result}") + # assert result.exit_code == 0 + + def test_cli_version(runner: CliRunner) -> None: """Check if version prints without error.""" cli_args = ["--version"]