Set up backend test infrastructure
Add pytest fixtures (engine, db_session, client) with session-scoped event loop to avoid asyncpg loop mismatch errors. Smoke tests verify all three main API endpoints return empty results on a clean DB. Test DB provided by docker-compose.test.yml on port 5433. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
31
backend/tests/test_smoke.py
Normal file
31
backend/tests/test_smoke.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Smoke tests that verify the test infrastructure is working correctly."""
|
||||
|
||||
|
||||
async def test_games_endpoint_returns_empty_list(client):
|
||||
"""Games endpoint returns an empty list on a clean database."""
|
||||
response = await client.get("/api/v1/games")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == []
|
||||
|
||||
|
||||
async def test_runs_endpoint_returns_empty_list(client):
|
||||
"""Runs endpoint returns an empty list on a clean database."""
|
||||
response = await client.get("/api/v1/runs")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == []
|
||||
|
||||
|
||||
async def test_pokemon_endpoint_returns_empty_list(client):
|
||||
"""Pokemon endpoint returns paginated empty result on a clean database."""
|
||||
response = await client.get("/api/v1/pokemon")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["items"] == []
|
||||
assert data["total"] == 0
|
||||
|
||||
|
||||
async def test_database_isolation_between_tests(client):
|
||||
"""Confirm state from previous tests does not leak into this one."""
|
||||
response = await client.get("/api/v1/games")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == []
|
||||
Reference in New Issue
Block a user