Skip to content

Commit

Permalink
test: add a cli test
Browse files Browse the repository at this point in the history
  • Loading branch information
vschaffn committed Nov 18, 2024
1 parent d94ccbe commit eb4dbb3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Function to test the CLI"""

import subprocess

import xdem


class TestCLI:
# Define paths to the DEM files using xDEM examples
ref_dem_path = xdem.examples.get_path("longyearbyen_ref_dem")
tba_dem_path = xdem.examples.get_path("longyearbyen_tba_dem")

def test_xdem_cli(self) -> None:
try:
# Run the xDEM CLI command with the reference and secondary DEM files
result = subprocess.run(
["xdem", self.ref_dem_path, self.tba_dem_path],
capture_output=True,
text=True,
)
assert "hello world" in result.stdout
assert result.returncode == 0

except FileNotFoundError as e:
# In case 'xdem' is not found
raise AssertionError(f"CLI command 'xdem' not found : {e}")

except Exception as e:
# Any other errors during subprocess run
raise AssertionError(f"An error occurred while running the CLI: {e}")

0 comments on commit eb4dbb3

Please sign in to comment.