# Backend test strategy (Anexo24) ## Test suites - `tests/e2e/`: full business flow (catalogs -> import -> export -> balances/discharges). - `tests/integration/`: process API behavior and edge cases. - `tests/unit/`: critical algorithms only (no trivial CRUD tests). ## Prerequisites - PostgreSQL test database available. - Environment variable: - `TEST_DATABASE_URL=postgresql://user:pass@host:5432/db_name` ## Run commands - Fast subset (CI gate): - `pytest -q tests/unit tests/integration` - Full suite: - `pytest -q tests` - `pytest tests -v -ra` - `pytest tests -v -ra -s` - E2E only: - `pytest -q tests/e2e` ## CI recommendations - Pull request gate: - Run unit + integration on every PR. - Nightly / main branch: - Run full suite including E2E. - Keep Celery eager mode for deterministic process endpoint tests: - `task_always_eager=True` - `task_eager_propagates=True`