Skip to main content

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

FlagEffect
-vVerbose — show each test name
-xStop on first failure
--tb=shortCompact tracebacks
-k "auth"Run only tests whose name matches auth
-qQuiet 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

FileWhat it covers
test_auth.pyToken issuance, access control, per-user env isolation (admin, alice, bob personas)
test_routes.pyRoot/healthz endpoints, region routes, 404 handling
test_services.pyEnvironment registry: create, list, delete, persist; raster import CRS decisions
test_grass_db.pyGRASS database path resolution and env scanning
test_profile_histogram_tools.pyProfile and histogram API routes
test_wfs.pyWFS proxy routes
test_wcs.pyWCS proxy routes
test_vector_edit.pyVector editing: commit, delete, move, attribute write
test_vector_style_frontend.pyVector style panel DOM helpers
test_db_manager.pyDB Manager API routes: SQLite and PostgreSQL inspection
test_db_manager_frontend.pyDB Manager DOM helper harness
test_analysis_artifacts.pyProfile/histogram artifact save, list, load, delete
test_published_projects.pyWorkspace publish / list / delete (web route surface)
test_published_projects_api.pyPublished project token-authenticated API surface
test_deploy_config.pyStructural sanity checks on Dockerfile and the Swarm compose file

Test fixtures

All fixtures are defined in tests/conftest.py.

FixtureDescription
factory_clientFresh FastAPI app with fakeredis and no Redis wait; admin user injected
api_clientThe real app singleton wired to the same admin override
create_api_envHelper that POSTs /grass/env and returns the created env
register_route_envMonkeypatches env_registry.get_env with a stub env
clear_registryAuto-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