diff --git a/CHANGELOG.md b/CHANGELOG.md index a91313a..c060ac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,21 @@ This project uses famous football coaches as release codenames, following an A-Z mutation key, full replace PUT, in-memory caching, integration-only tests (#482) +### Changed + +- Normalize player dataset: add Lo Celso (squad 27) as test fixture, + add Almada (squad 16) as seeded substitute, correct + Martínez/Fernández/Mac Allister/Messi field values, replace + pre-computed UUIDs with canonical UUID v5 values (namespace + `FIFA_WORLD_CUP_QATAR_2022_ARGENTINA_SQUAD`); bundled + `storage/players-sqlite3.db` rebuilt from seed scripts — Docker + deployments with a persisted volume will continue to use the old + database until the volume is recreated (`docker compose down -v && + docker compose up --build`) (#543) +- Align CRUD test fixtures: Lo Celso (squad 27) for Create and Delete, + Messi (squad 10) for Retrieve, Damián Martínez (squad 23) for Update + (#543) + --- ## [2.0.0 - Capello] - 2026-03-17 diff --git a/rest/players.rest b/rest/players.rest index 8a06ea4..584b2a1 100644 --- a/rest/players.rest +++ b/rest/players.rest @@ -20,7 +20,7 @@ Accept: application/json # ------------------------------------------------------------------------------ # POST /players/ — Create -# Thiago Almada (squad 16): not seeded in the database, used as the creation +# Giovani Lo Celso (squad 27): not seeded in the database, used as the creation # fixture. No id in the body; the server generates a UUID v4 on creation. # ------------------------------------------------------------------------------ @@ -29,15 +29,14 @@ POST {{baseUrl}}/players/ Content-Type: application/json { - "firstName": "Thiago", - "middleName": "Ezequiel", - "lastName": "Almada", - "dateOfBirth": "2001-04-26T00:00:00.000Z", - "squadNumber": 16, - "position": "Attacking Midfield", - "abbrPosition": "AM", - "team": "Atlanta United FC", - "league": "Major League Soccer", + "firstName": "Giovani", + "lastName": "Lo Celso", + "dateOfBirth": "1996-07-09T00:00:00.000Z", + "squadNumber": 27, + "position": "Central Midfield", + "abbrPosition": "CM", + "team": "Real Betis Balompié", + "league": "La Liga", "starting11": false } @@ -51,11 +50,11 @@ Accept: application/json # ------------------------------------------------------------------------------ # GET /players/{player_id} — Retrieve by UUID (surrogate key, internal) -# Emiliano Martínez (squad 23): UUID v5, seeded by seed_001. +# Lionel Messi (squad 10): UUID v5, seeded by seed_001. # ------------------------------------------------------------------------------ ### GET /players/{player_id} — Retrieve a Player by UUID -GET {{baseUrl}}/players/b04965e6-a9bb-591f-8f8a-1adcb2c8dc39 +GET {{baseUrl}}/players/acc433bf-d505-51fe-831e-45eb44c4d43c Accept: application/json # ------------------------------------------------------------------------------ @@ -69,7 +68,8 @@ Accept: application/json # ------------------------------------------------------------------------------ # PUT /players/squadnumber/{squad_number} — Update -# Emiliano Martínez (squad 23): seeded by seed_001. +# Damián Martínez (squad 23): seeded by seed_001. Updates firstName Damián → +# Emiliano and clears middleName. # ------------------------------------------------------------------------------ ### PUT /players/squadnumber/{squad_number} — Update an existing Player @@ -91,8 +91,8 @@ Content-Type: application/json # ------------------------------------------------------------------------------ # DELETE /players/squadnumber/{squad_number} — Delete -# Thiago Almada (squad 16): created by POST above. +# Giovani Lo Celso (squad 27): created by POST above. # ------------------------------------------------------------------------------ ### DELETE /players/squadnumber/{squad_number} — Delete an existing Player -DELETE {{baseUrl}}/players/squadnumber/16 +DELETE {{baseUrl}}/players/squadnumber/27 diff --git a/storage/players-sqlite3.db b/storage/players-sqlite3.db index 210be57..82dd18b 100644 Binary files a/storage/players-sqlite3.db and b/storage/players-sqlite3.db differ diff --git a/tests/player_stub.py b/tests/player_stub.py index e0dc2c6..ca67088 100644 --- a/tests/player_stub.py +++ b/tests/player_stub.py @@ -35,9 +35,9 @@ def existing_player(): Creates a test stub for an existing Player. """ return Player( - id="b04965e6-a9bb-591f-8f8a-1adcb2c8dc39", - first_name="Emiliano", - middle_name="", + id="01772c59-43f0-5d85-b913-c78e4e281452", + first_name="Damián", + middle_name="Emiliano", last_name="Martínez", date_of_birth="1992-09-02T00:00:00.000Z", squad_number=23, @@ -55,16 +55,15 @@ def nonexistent_player(): No id is provided; the server generates a UUID on creation. """ return Player( - first_name="Thiago", - middle_name="Ezequiel", - last_name="Almada", - date_of_birth="2001-04-26T00:00:00.000Z", - squad_number=16, - position="Attacking Midfield", - abbr_position="AM", - team="Atlanta United FC", - league="Major League Soccer", - starting11=0, + first_name="Giovani", + last_name="Lo Celso", + date_of_birth="1996-07-09T00:00:00.000Z", + squad_number=27, + position="Central Midfield", + abbr_position="CM", + team="Real Betis Balompié", + league="La Liga", + starting11=False, ) diff --git a/tests/test_main.py b/tests/test_main.py index 9ed2f73..dafbc79 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -225,13 +225,18 @@ def test_request_put_player_squadnumber_existing_response_status_no_content(clie squad_number = existing_player().squad_number player = existing_player() player.first_name = "Emiliano" - player.middle_name = "" - # Act - response = client.put( - PATH + "squadnumber/" + str(squad_number), json=player.__dict__ - ) - # Assert - assert response.status_code == 204 + player.middle_name = None + try: + # Act + response = client.put( + PATH + "squadnumber/" + str(squad_number), json=player.__dict__ + ) + # Assert + assert response.status_code == 204 + finally: + # Teardown — restore Damián Martínez to its seeded state + seed = existing_player() + client.put(PATH + "squadnumber/" + str(seed.squad_number), json=seed.__dict__) def test_request_put_player_squadnumber_mismatch_response_status_bad_request(client): diff --git a/tools/seed_001_starting_eleven.py b/tools/seed_001_starting_eleven.py index 0029173..be3e969 100644 --- a/tools/seed_001_starting_eleven.py +++ b/tools/seed_001_starting_eleven.py @@ -45,9 +45,9 @@ # --------------------------------------------------------------------------- STARTING_ELEVEN = [ { - "id": "b04965e6-a9bb-591f-8f8a-1adcb2c8dc39", - "firstName": "Emiliano", - "middleName": None, + "id": "01772c59-43f0-5d85-b913-c78e4e281452", + "firstName": "Damián", + "middleName": "Emiliano", "lastName": "Martínez", "dateOfBirth": "1992-09-02T00:00:00.000Z", "squadNumber": 23, @@ -58,7 +58,7 @@ "starting11": 1, }, { - "id": "4b166dbe-d99d-5091-abdd-95b83330ed3a", + "id": "da31293b-4c7e-5e0f-a168-469ee29ecbc4", "firstName": "Nahuel", "middleName": None, "lastName": "Molina", @@ -71,7 +71,7 @@ "starting11": 1, }, { - "id": "98123fde-012f-5ff3-8b50-881449dac91a", + "id": "c096c69e-762b-5281-9290-bb9c167a24a0", "firstName": "Cristian", "middleName": "Gabriel", "lastName": "Romero", @@ -84,7 +84,7 @@ "starting11": 1, }, { - "id": "6ed955c6-506a-5343-9be4-2c0afae02eef", + "id": "d5f7dd7a-1dcb-5960-ba27-e34865b63358", "firstName": "Nicolás", "middleName": "Hernán Gonzalo", "lastName": "Otamendi", @@ -97,7 +97,7 @@ "starting11": 1, }, { - "id": "c8691da2-158a-5ed6-8537-0e6f140801f2", + "id": "2f6f90a0-9b9d-5023-96d2-a2aaf03143a6", "firstName": "Nicolás", "middleName": "Alejandro", "lastName": "Tagliafico", @@ -110,7 +110,7 @@ "starting11": 1, }, { - "id": "a6c4fc8f-6950-51de-a9ae-2c519c465071", + "id": "b5b46e79-929e-5ed2-949d-0d167109c022", "firstName": "Ángel", "middleName": "Fabián", "lastName": "Di María", @@ -123,7 +123,7 @@ "starting11": 1, }, { - "id": "a9f96b98-dd44-5216-ab0d-dbfc6b262edf", + "id": "0293b282-1da8-562e-998e-83849b417a42", "firstName": "Rodrigo", "middleName": "Javier", "lastName": "de Paul", @@ -136,7 +136,7 @@ "starting11": 1, }, { - "id": "e99caacd-6c45-5906-bd9f-b79e62f25963", + "id": "d3ba552a-dac3-588a-b961-1ea7224017fd", "firstName": "Enzo", "middleName": "Jeremías", "lastName": "Fernández", @@ -144,12 +144,12 @@ "squadNumber": 24, "position": "Central Midfield", "abbrPosition": "CM", - "team": "Chelsea FC", - "league": "Premier League", + "team": "SL Benfica", + "league": "Liga Portugal", "starting11": 1, }, { - "id": "e4d80b30-151e-51b5-9f4f-18a3b82718e6", + "id": "9613cae9-16ab-5b54-937e-3135123b9e0d", "firstName": "Alexis", "middleName": None, "lastName": "Mac Allister", @@ -157,12 +157,12 @@ "squadNumber": 20, "position": "Central Midfield", "abbrPosition": "CM", - "team": "Liverpool FC", + "team": "Brighton & Hove Albion", "league": "Premier League", "starting11": 1, }, { - "id": "0159d6c7-973f-5e7a-a9a0-d195d0ea6fe2", + "id": "acc433bf-d505-51fe-831e-45eb44c4d43c", "firstName": "Lionel", "middleName": "Andrés", "lastName": "Messi", @@ -170,12 +170,12 @@ "squadNumber": 10, "position": "Right Winger", "abbrPosition": "RW", - "team": "Inter Miami CF", - "league": "Major League Soccer", + "team": "Paris Saint-Germain", + "league": "Ligue 1", "starting11": 1, }, { - "id": "7fef88f7-411d-5669-b42d-bf5fc7f9b58b", + "id": "38bae91d-8519-55a2-b30a-b9fe38849bfb", "firstName": "Julián", "middleName": None, "lastName": "Álvarez", diff --git a/tools/seed_002_substitutes.py b/tools/seed_002_substitutes.py index a64c481..dc454bb 100644 --- a/tools/seed_002_substitutes.py +++ b/tools/seed_002_substitutes.py @@ -1,7 +1,7 @@ """ Seed 002 – Substitutes -Seeds the 14 substitute players from the 2022 FIFA World Cup squad of the +Seeds the 15 substitute players from the 2022 FIFA World Cup squad of the Argentina national football team into an already-seeded `players` table (UUID primary key, created by Seed 001). @@ -13,7 +13,7 @@ Defaults to ./storage/players-sqlite3.db Idempotency: - If all 14 substitute UUIDs are already present the script exits without + If all 15 substitute UUIDs are already present the script exits without making any changes. Prerequisite: @@ -40,7 +40,7 @@ # --------------------------------------------------------------------------- SUBSTITUTES = [ { - "id": "52524d6e-10dc-5261-aa36-8b2efcbaa5f0", + "id": "5a9cd988-95e6-54c1-bc34-9aa08acca8d0", "firstName": "Franco", "middleName": "Daniel", "lastName": "Armani", @@ -53,7 +53,7 @@ "starting11": 0, }, { - "id": "91c274f2-9a0d-5ce6-ac3d-7529f452df21", + "id": "c62f2ac1-41e8-5d34-b073-2ba0913d0e31", "firstName": "Gerónimo", "middleName": None, "lastName": "Rulli", @@ -66,7 +66,7 @@ "starting11": 0, }, { - "id": "0ff1e264-520d-543a-87dd-181a491e667e", + "id": "5fdb10e8-38c0-5084-9a3f-b369a960b9c2", "firstName": "Juan", "middleName": "Marcos", "lastName": "Foyth", @@ -79,7 +79,7 @@ "starting11": 0, }, { - "id": "23986425-d3a5-5e13-8bab-299745777a8d", + "id": "bbd441f7-fcfb-5834-8468-2a9004b64c8c", "firstName": "Gonzalo", "middleName": "Ariel", "lastName": "Montiel", @@ -92,7 +92,7 @@ "starting11": 0, }, { - "id": "c15b38c9-9a3e-543c-a703-dd742f25b4d5", + "id": "d8bfea25-f189-5d5e-b3a5-ed89329b9f7c", "firstName": "Germán", "middleName": "Alejo", "lastName": "Pezzella", @@ -105,7 +105,7 @@ "starting11": 0, }, { - "id": "db680066-c83d-5ed7-89a4-1d79466ea62d", + "id": "dca343a8-12e5-53d6-89a8-916b120a5ee4", "firstName": "Marcos", "middleName": "Javier", "lastName": "Acuña", @@ -118,7 +118,7 @@ "starting11": 0, }, { - "id": "cadb7952-2bba-5609-88d4-8e47ec4e7920", + "id": "98306555-a466-5d18-804e-dc82175e697b", "firstName": "Lisandro", "middleName": None, "lastName": "Martínez", @@ -131,7 +131,7 @@ "starting11": 0, }, { - "id": "35140057-a2a4-5adb-a500-46f8ed8b66a9", + "id": "9d140400-196f-55d8-86e1-e0b96a375c83", "firstName": "Leandro", "middleName": "Daniel", "lastName": "Paredes", @@ -144,7 +144,7 @@ "starting11": 0, }, { - "id": "66e549b7-01e2-5d07-98d5-430f74d8d3b2", + "id": "d3b0e8e8-2c34-531a-b608-b24fed0ef986", "firstName": "Exequiel", "middleName": "Alejandro", "lastName": "Palacios", @@ -157,7 +157,7 @@ "starting11": 0, }, { - "id": "292c8e99-2378-55aa-83d8-350e0ac3f1cc", + "id": "7cc8d527-56a2-58bd-9528-2618fc139d30", "firstName": "Alejandro", "middleName": "Darío", "lastName": "Gómez", @@ -170,7 +170,7 @@ "starting11": 0, }, { - "id": "0e3b230a-0509-55d8-96a0-9875f387a2be", + "id": "191c82af-0c51-526a-b903-c3600b61b506", "firstName": "Guido", "middleName": None, "lastName": "Rodríguez", @@ -183,7 +183,7 @@ "starting11": 0, }, { - "id": "4c507660-a83b-55c0-9b2b-83eccb07723d", + "id": "b1306b7b-a3a4-5f7c-90fd-dd5bdbed57ba", "firstName": "Ángel", "middleName": "Martín", "lastName": "Correa", @@ -196,7 +196,20 @@ "starting11": 0, }, { - "id": "c2708a8b-120a-56f5-a30d-990048af87cc", + "id": "ecec27e8-487b-5622-b116-0855020477ed", + "firstName": "Thiago", + "middleName": "Ezequiel", + "lastName": "Almada", + "dateOfBirth": "2001-04-26T00:00:00.000Z", + "squadNumber": 16, + "position": "Attacking Midfield", + "abbrPosition": "AM", + "team": "Atlanta United FC", + "league": "Major League Soccer", + "starting11": 0, + }, + { + "id": "7941cd7c-4df1-5952-97e8-1e7f5d08e8aa", "firstName": "Paulo", "middleName": "Exequiel", "lastName": "Dybala", @@ -209,7 +222,7 @@ "starting11": 0, }, { - "id": "e7263999-68b6-5a23-b530-af25b7efd632", + "id": "79c96f29-c59f-5f98-96b8-3a5946246624", "firstName": "Lautaro", "middleName": "Javier", "lastName": "Martínez", @@ -242,7 +255,7 @@ def _table_exists(conn: sqlite3.Connection) -> bool: def _already_migrated(conn: sqlite3.Connection) -> bool: - """Return True when all 14 substitute UUIDs are already in the table.""" + """Return True when all 15 substitute UUIDs are already in the table.""" uuids = [p["id"] for p in SUBSTITUTES] placeholders = ",".join("?" * len(uuids)) cursor = conn.execute(