36 lines
1.5 KiB
Markdown
36 lines
1.5 KiB
Markdown
---
|
|
# nuzlocke-tracker-rrcf
|
|
title: Set up backend test infrastructure
|
|
status: draft
|
|
type: task
|
|
priority: normal
|
|
created_at: 2026-02-10T09:32:57Z
|
|
updated_at: 2026-02-10T09:33:59Z
|
|
parent: nuzlocke-tracker-yzpb
|
|
blocking:
|
|
- 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) |