Running Tests
FastGIS uses pytest with httpx for API integration tests and fakeredis for Redis-dependent tests — no live services are required.
Setup
Install the dev dependencies (a superset of requirements.txt):
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
Run the full test suite
pytest
pytest discovers all tests/test_*.py files automatically. Redis is replaced with an in-process fake via monkeypatch.
Useful flags
| Flag | Effect |
|---|---|
-v | Verbose — show each test name |
-x | Stop on first failure |
--tb=short | Compact tracebacks |
-k "auth" | Run only tests whose name matches auth |
-q | Quiet mode — dots only |
Focused suites
# Core routes + services
GRASS_COMPAT=1 pytest tests/test_deploy_config.py tests/test_routes.py tests/test_services.py --tb=short
# DB Manager + WFS + vector style
pytest tests/test_db_manager.py tests/test_db_manager_frontend.py tests/test_wfs.py tests/test_vector_style_frontend.py --tb=short
# PostgreSQL / vector attribute path
pytest tests/test_services.py tests/test_db_manager.py tests/test_wfs.py tests/test_vector_edit.py --tb=short
# Analysis artifacts + published projects
pytest tests/test_analysis_artifacts.py tests/test_published_projects.py tests/test_published_projects_api.py -q
# Raster import CRS decisions
pytest tests/test_services.py -k 'import_raster_' --tb=short -q
# JS UI helper harness
npm run test:ui
Test modules
| File | What it covers |
|---|---|
test_auth.py | Token issuance, access control, per-user env isolation (admin, alice, bob personas) |
test_routes.py | Root/healthz endpoints, region routes, 404 handling |
test_services.py | Environment registry: create, list, delete, persist; raster import CRS decisions |
test_grass_db.py | GRASS database path resolution and env scanning |
test_profile_histogram_tools.py | Profile and histogram API routes |
test_wfs.py | WFS proxy routes |
test_wcs.py | WCS proxy routes |
test_vector_edit.py | Vector editing: commit, delete, move, attribute write |
test_vector_style_frontend.py | Vector style panel DOM helpers |
test_db_manager.py | DB Manager API routes: SQLite and PostgreSQL inspection |
test_db_manager_frontend.py | DB Manager DOM helper harness |
test_analysis_artifacts.py | Profile/histogram artifact save, list, load, delete |
test_published_projects.py | Workspace publish / list / delete (web route surface) |
test_published_projects_api.py | Published project token-authenticated API surface |
test_deploy_config.py | Structural sanity checks on Dockerfile and the Swarm compose file |
Test fixtures
All fixtures are defined in tests/conftest.py.
| Fixture | Description |
|---|---|
factory_client | Fresh FastAPI app with fakeredis and no Redis wait; admin user injected |
api_client | The real app singleton wired to the same admin override |
create_api_env | Helper that POSTs /grass/env and returns the created env |
register_route_env | Monkeypatches env_registry.get_env with a stub env |
clear_registry | Auto-use: clears env registry before and after every test |
Running against a real Redis
REDIS_URL=redis://localhost:6379/1 pytest
Use database 1 (or higher) to avoid polluting the development database.
Mobile TypeScript check
npm run mobile:typecheck
# or
cd mobile-app && npx tsc --noEmit
Linting
ruff check app/
ruff is not in requirements-dev.txt by default; install it with:
pip install ruff