Testing¶
Test Setup¶
Tests use pytest with httpx.AsyncClient and a dedicated PostgreSQL 18
database (argus_test, created and migrated automatically by conftest.py).
The real schema — including the generated slug column and the public.slugify
function — is exercised exactly as in production.
Run all tests:
Run tests standalone with just postgres + rabbitmq (no full stack, no host port bindings):
Test Configuration¶
pytest-asynciowithasyncio_mode = "auto"(set inpyproject.toml)conftest.pyprovides fixtures for test database, HTTP client, and auth- Tests are in
app/tests/
Running Specific Tests¶
# Single file
docker compose exec app pytest tests/test_api.py -v
# Single test
docker compose exec app pytest tests/test_api.py::test_create_project -v
# With coverage
docker compose exec app pytest -v --cov=. --cov-report=term-missing
Test Structure¶
| File | Tests |
|---|---|
tests/test_api.py |
REST API endpoints (61 tests) |
tests/test_sbom_parser.py |
SBOM parsing (CycloneDX, SPDX) |
Quality Gates¶
Before committing, the following must pass:
- Lint:
ruff check app/ - Format:
ruff format app/ --check - SAST:
bandit -c pyproject.toml -r app/ - SCA:
pip-audit --require-hashes --disable-pip -r requirements/remote.txt - Tests:
pytest -v
Use the shortcut:
CI / Pre-commit Hooks¶
Pre-commit is configured in .pre-commit-config.yaml and runs:
Install hooks once: