Skip to content

feat(data): normalize dataset to 2022 FIFA World Cup squad (#543)#546

Merged
nanotaboada merged 2 commits intomasterfrom
feat/normalize-dataset-543
Apr 1, 2026
Merged

feat(data): normalize dataset to 2022 FIFA World Cup squad (#543)#546
nanotaboada merged 2 commits intomasterfrom
feat/normalize-dataset-543

Conversation

@nanotaboada
Copy link
Copy Markdown
Owner

@nanotaboada nanotaboada commented Mar 31, 2026

Summary

  • 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_substitutes.py
  • Add Lo Celso (squad 27) as Create/Delete test fixture (not seeded — squad 27 sits outside the 1–26 seeded range)
  • Correct field values to November 2022: Martínez firstName/middleName, Fernández team/league, Mac Allister team, Messi team/league
  • Add PUT teardown to restore Damián Martínez to seeded state 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

Closes #543

Test plan

  • flake8 — no issues
  • black --check — no changes needed
  • pytest — 20/20 passed
  • Coverage — 100%

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • Tests

    • Updated player test fixtures and request semantics; aligned CRUD scenarios and added cleanup to restore seeded state after PUT tests.
  • Chores

    • Refreshed seeded roster and substitute data for consistency: added one substitute, standardized identifiers, and corrected player profile and team/league values.

- 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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ac8db58a-73bf-4e5d-922e-363237298b86

📥 Commits

Reviewing files that changed from the base of the PR and between b99ef30 and 8c4b284.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • tests/test_main.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG.md
  • tests/test_main.py

Walkthrough

Normalize 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

Cohort / File(s) Summary
Seed data — Starting XI
tools/seed_001_starting_eleven.py
Replaced multiple player UUIDs with deterministic UUID v5 values; updated first/middle name for Martínez and several players' team/league fields; data-only edits, insertion logic unchanged.
Seed data — Substitutes
tools/seed_002_substitutes.py
Replaced substitute UUIDs with UUID v5 values; added Thiago Almada (squad 16) to SUBSTITUTES, increasing seeded count (docstring and idempotency checks updated).
Test stubs
tests/player_stub.py
Updated existing_player() to canonical Martínez values and UUID; updated nonexistent_player() to Lo Celso (squad 27) test fixture and adjusted literal field types/values.
Tests
tests/test_main.py
PUT test now sets middle_name to None and wraps assert flow in try/finally to PUT seeded player state back (teardown restore).
REST client fixtures
rest/players.rest
Updated POST/GET/PUT/DELETE examples and comments: create/delete use Lo Celso (squad 27), GET targets Messi UUID, PUT comment aligns with Martínez semantics (payload semantics adjusted in tests).
Changelog
CHANGELOG.md
Added [Unreleased] entry documenting player fixture updates, canonical UUID v5 replacements, field corrections, and CRUD fixture mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
Normalize dataset to canonical 26-player Argentina squad; use Lo Celso as test fixture; add Thiago Almada to substitutes [#543]
Correct specified player fields: Damián Martínez (middleName → "Emiliano"), Enzo Fernández (team/league → SL Benfica/Liga Portugal), Alexis Mac Allister (team → Brighton & Hove Albion), Lionel Messi (team/league → Paris Saint-Germain/Ligue 1) [#543]
Replace precomputed UUIDs with canonical UUID v5 using namespace f201b13e-c670-473d-885d-e2be219f74c8 and mapping; update seed scripts and tests [#543]
Align tests and REST fixtures: tests/player_stub.py, tests/test_main.py, rest/players.rest mapping and teardown behavior [#543]

Out-of-scope changes

No 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)
Check name Status Explanation
Title check ✅ Passed The title uses the Conventional Commits format (feat: prefix), is under 80 characters (65 chars), and clearly describes the main change: normalizing the dataset to the 2022 FIFA World Cup squad, which aligns directly with all file changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/normalize-dataset-543
  • 🛠️ sync documentation: Commit on current branch
  • 🛠️ sync documentation: Create PR
  • 🛠️ enforce http error handling: Commit on current branch
  • 🛠️ enforce http error handling: Create PR
  • 🛠️ idiomatic review: Commit on current branch
  • 🛠️ idiomatic review: Create PR
  • 🛠️ verify api contract: Commit on current branch
  • 🛠️ verify api contract: Create PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a81abcd) to head (8c4b284).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #546   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          113       113           
=========================================
  Hits           113       113           
Components Coverage Δ
Services 100.00% <ø> (ø)
Routes 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Run the restore PUT in a finally and source it from the stub.

This test writes to the shared seeded DB. If the first PUT or the 204 assertion 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 == 204

Based 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

📥 Commits

Reviewing files that changed from the base of the PR and between a81abcd and b99ef30.

⛔ Files ignored due to path filters (1)
  • storage/players-sqlite3.db is excluded by !**/*.db, !**/storage/**, !**/*.db
📒 Files selected for processing (6)
  • CHANGELOG.md
  • rest/players.rest
  • tests/player_stub.py
  • tests/test_main.py
  • tools/seed_001_starting_eleven.py
  • tools/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>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

@nanotaboada nanotaboada merged commit a1f86bb into master Apr 1, 2026
13 checks passed
@nanotaboada nanotaboada deleted the feat/normalize-dataset-543 branch April 1, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Normalize player dataset to 2022 FIFA World Cup Argentina squad (26 players)

1 participant