Premier League Predictor: FastAPI & Redis — Chapter 10, Exercise 2 ================================================================== TASK Call the create-fixture route with a team playing itself, with a nonexistent season, and request an empty but valid gameweek's state. Report the status code and body for each, and whether anything was left behind in Redis. SOLUTION Team playing itself: POST /api/gameweeks/2/9/fixtures {"home_team_id": 3, "away_team_id": 3} -> 400 {'error': 'a team cannot play itself'} used_teams for gameweek 2/9: empty set (nothing claimed) Nonexistent season: POST /api/gameweeks/99/1/fixtures {"home_team_id": 1, "away_team_id": 2} -> 404 {'error': 'no such season'} EXISTS gameweek:99:1:used_teams -> 0 (nothing created) Empty but valid gameweek (season 2 exists; gameweek 30 has no fixtures): GET /api/gameweeks/2/30 -> 200, fixtures: [], used_team_ids: [] The first two are refused before any write, so nothing is left in Redis. The season check is what stops a typo'd season ID from silently creating a used_teams set, a fixture and a gameweek entry for a season that doesn't exist - the missing-foreign-key problem from Chapter 2 again. The third is deliberately a success: the season is real, the gameweek is simply empty, and the page needs a 200 with empty lists to render "No fixtures entered yet". WHY THIS WORKS AS AN ANSWER ---------------------------- It distinguishes the three cases by status code, confirms with real checks that the refusals leave nothing behind, and explains why the empty gameweek is a 200 rather than a 404.