Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions rest/players.rest
Original file line number Diff line number Diff line change
Expand Up @@ -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.
# ------------------------------------------------------------------------------

Expand All @@ -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
}

Expand All @@ -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

# ------------------------------------------------------------------------------
Expand All @@ -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
Expand All @@ -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
Binary file modified storage/players-sqlite3.db
Binary file not shown.
25 changes: 12 additions & 13 deletions tests/player_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)


Expand Down
19 changes: 12 additions & 7 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
36 changes: 18 additions & 18 deletions tools/seed_001_starting_eleven.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -58,7 +58,7 @@
"starting11": 1,
},
{
"id": "4b166dbe-d99d-5091-abdd-95b83330ed3a",
"id": "da31293b-4c7e-5e0f-a168-469ee29ecbc4",
"firstName": "Nahuel",
"middleName": None,
"lastName": "Molina",
Expand All @@ -71,7 +71,7 @@
"starting11": 1,
},
{
"id": "98123fde-012f-5ff3-8b50-881449dac91a",
"id": "c096c69e-762b-5281-9290-bb9c167a24a0",
"firstName": "Cristian",
"middleName": "Gabriel",
"lastName": "Romero",
Expand All @@ -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",
Expand All @@ -92,12 +92,12 @@
"squadNumber": 19,
"position": "Centre-Back",
"abbrPosition": "CB",
"team": "SL Benfica",

Check failure on line 95 in tools/seed_001_starting_eleven.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "SL Benfica" 3 times.

See more on https://sonarcloud.io/project/issues?id=nanotaboada_python-samples-fastapi-restful&issues=AZ1FtiQRxuRvoptrNQ2_&open=AZ1FtiQRxuRvoptrNQ2_&pullRequest=546
"league": "Liga Portugal",

Check failure on line 96 in tools/seed_001_starting_eleven.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Liga Portugal" 3 times.

See more on https://sonarcloud.io/project/issues?id=nanotaboada_python-samples-fastapi-restful&issues=AZ1FtiQRxuRvoptrNQ3A&open=AZ1FtiQRxuRvoptrNQ3A&pullRequest=546
"starting11": 1,
},
{
"id": "c8691da2-158a-5ed6-8537-0e6f140801f2",
"id": "2f6f90a0-9b9d-5023-96d2-a2aaf03143a6",
"firstName": "Nicolás",
"middleName": "Alejandro",
"lastName": "Tagliafico",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -136,46 +136,46 @@
"starting11": 1,
},
{
"id": "e99caacd-6c45-5906-bd9f-b79e62f25963",
"id": "d3ba552a-dac3-588a-b961-1ea7224017fd",
"firstName": "Enzo",
"middleName": "Jeremías",
"lastName": "Fernández",
"dateOfBirth": "2001-01-17T00:00:00.000Z",
"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",
"dateOfBirth": "1998-12-24T00:00:00.000Z",
"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",
"dateOfBirth": "1987-06-24T00:00:00.000Z",
"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",
Expand Down
Loading
Loading