Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ jobs:
- name: Sync dependencies (locked)
run: uv sync --all-groups --frozen --python ${{ matrix.python-version }}
- name: Run tests
env:
# The app instantiates Settings() at import time, which requires a valid
# DATABASE_URL (PostgresDsn). The test suite is fully mocked and never opens
# a real connection, so a well-formed dummy DSN is sufficient to let the
# package import and the suite collect/run. Add a `postgres` service block
# here (e.g. postgis/postgis image) if/when tests exercise a live database.
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/suhail_pipeline
run: uv run pytest
22 changes: 18 additions & 4 deletions tests/unit/test_geometric_cli.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import re

from typer.testing import CliRunner
from suhail_pipeline.run_geometric_pipeline import app

runner = CliRunner()

# Typer/Rich colourises option names in help output (e.g. in CI, FORCE_COLOR),
# rendering "--bbox" as "\x1b[..m-\x1b[0m\x1b[..m-bbox\x1b[0m" so a literal
# substring check fails even though the option is present. Strip ANSI first.
_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")


def _plain(text: str) -> str:
return _ANSI_RE.sub("", text)


def test_geometric_cli_invalid_bbox():
# Should fail with invalid bbox length
result = runner.invoke(app, ["--bbox", "1", "2", "3"]) # Only 3 values
assert result.exit_code != 0
# Check both stdout and stderr for the error message
output = result.stdout + getattr(result, 'stderr', '')
output = _plain(result.stdout + getattr(result, "stderr", ""))
assert ("Bounding box must be 4 floats" in output) or ("Usage:" in output)


def test_geometric_cli_help():
result = runner.invoke(app, ["--help"])
assert result.exit_code == 0
assert "--bbox" in result.stdout
assert "--province" in result.stdout
assert "--saudi-arabia" in result.stdout
out = _plain(result.stdout)
assert "--bbox" in out
assert "--province" in out
assert "--saudi-arabia" in out
Loading