Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markspec authored and tasansal committed Aug 25, 2023
1 parent 22a8d6d commit 893a552
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
23 changes: 23 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
Expand Down

0 comments on commit 893a552

Please sign in to comment.