Skip to content

Issue 08: Pytest Harness #8

@laraibg786

Description

@laraibg786

Goal

Establish a pytest testing foundation with reusable fixtures for unit and integration tests.

Requirements

Functional

  • Create conftest.py with shared fixtures: app, client, db_session, auth_headers.
  • Define test markers: unit and integration.
  • Implement deterministic database cleanup between tests (transactional rollback or truncate).
  • Ensure tests are isolated and do not share state.

Technical

  • Framework: pytest with pytest-asyncio if async routes are used.
  • Test Client: FastAPI TestClient (or AsyncClient for async).
  • DB Isolation: Each test runs in a transaction that is rolled back after the test.
  • Fixtures: db_session provides a scoped DB session; auth_headers provides a valid JWT for authenticated tests.
  • Configuration: pytest.ini or pyproject.toml with marker definitions.

Acceptance Criteria

  • pytest runs successfully with zero tests (empty suite).
  • db_session fixture provides a clean DB state for each test.
  • auth_headers fixture provides valid JWT headers for protected endpoint tests.
  • Tests can be filtered by unit and integration markers.

Dependencies

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions