Files
nuzlocke-tracker/.beans/nuzlocke-tracker-rrcf--set-up-backend-test-infrastructure.md
Julian Tabel 6f4ed3460b Add Unit & Integration Tests epic with subtasks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 10:34:45 +01:00

1.5 KiB

title, status, type, priority, created_at, updated_at, parent, blocking
title status type priority created_at updated_at parent blocking
Set up backend test infrastructure draft task normal 2026-02-10T09:32:57Z 2026-02-10T09:33:59Z nuzlocke-tracker-yzpb
nuzlocke-tracker-hjkk
nuzlocke-tracker-iam7
nuzlocke-tracker-ch77
nuzlocke-tracker-ugb7
nuzlocke-tracker-0arz
nuzlocke-tracker-9c66

Set up the foundational test infrastructure for the FastAPI backend so that all subsequent test tasks can build on it.

Checklist

  • Create backend/tests/conftest.py with shared fixtures
  • Set up a test database strategy (use a separate test PostgreSQL database or SQLite for speed — evaluate trade-offs)
  • Create an async test client fixture using httpx.AsyncClient with the FastAPI app
  • Create a database session fixture that creates/drops tables per test session or uses transactions for isolation
  • Add factory fixtures or helpers for creating common test entities (games, pokemon, runs, etc.)
  • Verify the setup works by writing a simple smoke test (e.g. health endpoint returns 200)
  • Document how to run tests (e.g. pytest from backend dir, any env vars needed)

Notes

  • pytest, pytest-asyncio, and httpx are already in pyproject.toml dev dependencies
  • AsyncIO mode is set to "auto" in pyproject.toml
  • The app uses SQLAlchemy async with asyncpg — test fixtures need to handle async session management
  • Consider using SAVEPOINT-based transaction rollback for test isolation (faster than recreating tables)