7.2 Backend tests
Backend coverage is integrated into the main tests/ directory. While these tests are run using the same pytest runner as the pipeline, they specifically target Flask blueprints, SQLAlchemy models, and API services.
Current Backend Coverage
The following test files provide coverage for the backend and API layers:
| File | What it covers |
|---|---|
tests/test_async_export_payloads.py |
Validates asynchronous report generation and documentation PDF export endpoints. |
tests/test_filter_semantics.py |
Extensive tests for QueryBuilder logic and filter parameter resolution. |
tests/test_docs_links.py |
Validates documentation routes and rendered internal links. |
tests/test_search_security.py |
Ensures the search API is protected against common injection or abuse patterns. |
tests/test_global_stats_service.py |
Validates the logic for aggregating and serving global filtering statistics. |
tests/matching_pipeline/test_validators.py |
Covers input validation, pagination, and sanitization services. |
Running the Backend Tests
It is recommended to use the test service in Docker to ensure all web dependencies (like weasyprint for PDFs and flask-testing) are available.
docker compose run --rm --no-deps --entrypoint '' \
-e DATABASE_URI=sqlite:// \
-e FLASK_ENV=testing \
test python -m pytest tests/test_async_export_payloads.py tests/test_filter_semantics.py tests/test_docs_links.py -v
Testing Methodology
- In-Memory Database: Most backend tests use
sqlite:///:memory:to stay fast and avoid side effects. - Fixture Support: Shared fixtures in
tests/conftest.pyprovide a configured Flaskclientand synthetic data generators. - Blueprint Isolation: Many tests rely on
monkeypatchto isolate API logic from long-running background tasks (e.g., PDF generation).
Remaining Gaps
While core API logic and filters are well-covered, areas such as fine-grained CRUD operations for all database models and complex interactive search result ranking still rely partly on end-to-end integration tests.