# Backend Tests Rules This file governs `backend/tests/**` only. ## Scope & Precedence - Inherits root `AGENTS.md` and `backend/AGENTS.md`. - If rules conflict, apply the stricter one. ## Test Execution - Use `uv run pytest ...` for all backend test commands. - Unit tests should not depend on a running web process. - Integration tests under `backend/tests/integration` are live API tests and must run against a started backend. ## Integration Tests (Required Precondition) - Before running integration tests, start backend and workers with: - `./infra/scripts/app.sh restart` - Verify service readiness via `/health` before sending test requests. - Integration tests may write test data to database, but must clean up created records after each test. ## Data Safety - Test data must use isolated identifiers (unique email suffix, unique run_id/thread_id). - Cleanup must include auth users and related bonus/audit records created by the test. - Never hardcode production credentials or mutable shared user IDs in tests.