feat(data): normalize dataset to 2022 FIFA World Cup squad (#543)#546
feat(data): normalize dataset to 2022 FIFA World Cup squad (#543)#546nanotaboada merged 2 commits intomasterfrom
Conversation
- Replace all 26 pre-computed UUIDs with canonical UUID v5 values (namespace FIFA_WORLD_CUP_QATAR_2022_ARGENTINA_SQUAD) - Add Almada (squad 16) as seeded substitute in seed_002 - Add Lo Celso (squad 27) as Create/Delete test fixture in player_stub - Correct Martínez firstName/middleName, Fernández team/league, Mac Allister team, Messi team/league to November 2022 values - Add PUT teardown to restore Martínez after each test run - Rebuild storage/players-sqlite3.db from updated seed scripts - Update rest/players.rest: Lo Celso for POST/DELETE, Messi UUID for GET by id, Damián→Emiliano semantics for PUT Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughNormalize Argentina 2022 player seeds to canonical 26-player squad and Lo Celso as test fixture; replace precomputed UUIDs with canonical UUID v5 values; correct specific player fields (Martínez/Enzo Fernández/Mac Allister/Messi); add Thiago Almada as a seeded substitute; update tests and REST client fixtures to align with these changes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Assessment against linked issues
Out-of-scope changesNo out-of-scope functional code changes detected relative to the linked issue objectives. Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #546 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 113 113
=========================================
Hits 113 113
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/test_main.py (1)
222-250:⚠️ Potential issue | 🟠 MajorRun the restore PUT in a
finallyand source it from the stub.This test writes to the shared seeded DB. If the first PUT or the
204assertion fails, the cleanup is skipped; keeping a second hardcoded Martínez payload here also makes fixture drift easy.♻️ Suggested cleanup pattern
def test_request_put_player_squadnumber_existing_response_status_no_content(client): """PUT /players/squadnumber/{squad_number} with existing number returns 204 No Content""" # Arrange squad_number = existing_player().squad_number player = existing_player() + restore_player = existing_player() player.first_name = "Emiliano" player.middle_name = None # Act - response = client.put( - PATH + "squadnumber/" + str(squad_number), json=player.__dict__ - ) - # Assert - assert response.status_code == 204 - # Teardown — restore Damián Martínez to its seeded state - client.put( - PATH + "squadnumber/23", - json={ - "firstName": "Damián", - "middleName": "Emiliano", - "lastName": "Martínez", - "dateOfBirth": "1992-09-02T00:00:00.000Z", - "squadNumber": 23, - "position": "Goalkeeper", - "abbrPosition": "GK", - "team": "Aston Villa FC", - "league": "Premier League", - "starting11": True, - }, - ) + try: + response = client.put( + PATH + f"squadnumber/{squad_number}", json=player.__dict__ + ) + # Assert + assert response.status_code == 204 + finally: + restore_response = client.put( + PATH + f"squadnumber/{restore_player.squad_number}", + json={ + "firstName": restore_player.first_name, + "middleName": restore_player.middle_name, + "lastName": restore_player.last_name, + "dateOfBirth": restore_player.date_of_birth, + "squadNumber": restore_player.squad_number, + "position": restore_player.position, + "abbrPosition": restore_player.abbr_position, + "team": restore_player.team, + "league": restore_player.league, + "starting11": bool(restore_player.starting11), + }, + ) + assert restore_response.status_code == 204Based on learnings: "Integration tests against the real pre-seeded SQLite DB via TestClient" and "use tests/player_stub.py for test data".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_main.py` around lines 222 - 250, The teardown PUT in test_request_put_player_squadnumber_existing_response_status_no_content must be moved into a finally block so cleanup runs even if the test fails; replace the hardcoded Martínez JSON with the canonical stub from tests/player_stub.py (use the existing_player() or the named stub object from player_stub) and call client.put(PATH + "squadnumber/23", json=stub.__dict__ or stub_payload) inside that finally to restore the seeded record; keep the arrange/act/assert logic unchanged and reference existing_player(), PATH and the test function name to locate the changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Around line 54-61: Add a short note to the same release entry in CHANGELOG.md
(the bullet list that mentions Normalizing player dataset and Align CRUD test
fixtures) explaining that the PR rebuilt the bundled SQLite DB and that existing
Docker deployments with a persisted volume will continue to use the old
players-sqlite3.db unless the Docker volume is recreated; explicitly instruct
users to recreate or reset the Docker volume (or remove the persisted
players-sqlite3.db) to pick up the normalized squad data.
---
Outside diff comments:
In `@tests/test_main.py`:
- Around line 222-250: The teardown PUT in
test_request_put_player_squadnumber_existing_response_status_no_content must be
moved into a finally block so cleanup runs even if the test fails; replace the
hardcoded Martínez JSON with the canonical stub from tests/player_stub.py (use
the existing_player() or the named stub object from player_stub) and call
client.put(PATH + "squadnumber/23", json=stub.__dict__ or stub_payload) inside
that finally to restore the seeded record; keep the arrange/act/assert logic
unchanged and reference existing_player(), PATH and the test function name to
locate the changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b6a3a965-c9d7-4b64-bcf2-d4e355b6b46f
⛔ Files ignored due to path filters (1)
storage/players-sqlite3.dbis excluded by!**/*.db,!**/storage/**,!**/*.db
📒 Files selected for processing (6)
CHANGELOG.mdrest/players.resttests/player_stub.pytests/test_main.pytools/seed_001_starting_eleven.pytools/seed_002_substitutes.py
- CHANGELOG: add Docker volume note to dataset normalization entry - test: wrap PUT act/assert in try/finally so teardown runs on failure; replace hardcoded Martínez JSON with existing_player() stub Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
|



Summary
FIFA_WORLD_CUP_QATAR_2022_ARGENTINA_SQUAD)seed_002_substitutes.pyfirstName/middleName, Fernándezteam/league, Mac Allisterteam, Messiteam/leaguestorage/players-sqlite3.dbfrom updated seed scriptsrest/players.rest: Lo Celso for POST/DELETE, Messi UUID for GET by id, Damián→Emiliano semantics for PUTCloses #543
Test plan
flake8— no issuesblack --check— no changes neededpytest— 20/20 passed🤖 Generated with Claude Code
This change is
Summary by CodeRabbit
Tests
Chores