-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Goal
Establish a pytest testing foundation with reusable fixtures for unit and integration tests.
Requirements
Functional
- Create
conftest.pywith shared fixtures:app,client,db_session,auth_headers. - Define test markers:
unitandintegration. - Implement deterministic database cleanup between tests (transactional rollback or truncate).
- Ensure tests are isolated and do not share state.
Technical
- Framework: pytest with
pytest-asyncioif async routes are used. - Test Client: FastAPI
TestClient(orAsyncClientfor async). - DB Isolation: Each test runs in a transaction that is rolled back after the test.
- Fixtures:
db_sessionprovides a scoped DB session;auth_headersprovides a valid JWT for authenticated tests. - Configuration:
pytest.iniorpyproject.tomlwith marker definitions.
Acceptance Criteria
-
pytestruns successfully with zero tests (empty suite). -
db_sessionfixture provides a clean DB state for each test. -
auth_headersfixture provides valid JWT headers for protected endpoint tests. - Tests can be filtered by
unitandintegrationmarkers.
Dependencies
Reactions are currently unavailable