Skip to content

Commit a2ecf98

Browse files
authored
Merge pull request #560 from nanotaboada/test/559-normalize-player-stub-to-fake
test(tests): normalize player stub to fake, rename 404 test (#559)
2 parents c07988a + 798a706 commit a2ecf98

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ This project uses famous football coaches as release codenames, following an A-Z
5353

5454
### Changed
5555

56+
- `tests/player_stub.py` renamed to `tests/player_fake.py`; class docstring
57+
updated to reflect fake (not stub) role; module-level docstring added
58+
documenting the three-term data-state vocabulary (`existing`, `nonexistent`,
59+
`unknown`); imports in `conftest.py` and `test_main.py` updated accordingly;
60+
`test_request_get_player_id_nonexistent_response_status_not_found` renamed to
61+
`test_request_get_player_id_unknown_response_status_not_found` (#559)
5662
- `GET /players/` cache check changed from `if not players` to
5763
`if players is None` so that an empty collection is cached correctly
5864
instead of triggering a DB fetch on every request (#530)

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
from fastapi.testclient import TestClient
66
from main import app
7-
from tests.player_stub import Player, nonexistent_player
7+
from tests.player_fake import Player, nonexistent_player
88

99
# Suppress the DeprecationWarning from httpx
1010
warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -31,7 +31,7 @@ def nonexistent_player_in_db(client: Any) -> Generator[Player, None, None]:
3131
Creates the nonexistent player in the database and removes it on teardown.
3232
3333
Yields:
34-
Player: The player stub created in the database.
34+
Player: The fake player created in the database.
3535
"""
3636
player: Player = nonexistent_player()
3737
client.post("/players/", json=player.__dict__)
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
"""
2+
Test fakes for Player data-state scenarios.
3+
4+
Three-term vocabulary:
5+
existing — player is present in the database
6+
nonexistent — player is absent, valid shape for creation (POST scenarios)
7+
unknown — valid ID format, absent from database (404-by-lookup scenarios)
8+
"""
9+
10+
111
class Player:
212
"""
3-
Test stub representing a Player.
13+
Test fake representing a Player.
414
"""
515

616
def __init__(
@@ -30,9 +40,9 @@ def __init__(
3040
self.starting11 = starting11
3141

3242

33-
def existing_player():
43+
def existing_player() -> Player:
3444
"""
35-
Creates a test stub for an existing Player.
45+
Creates a test fake for an existing Player.
3646
"""
3747
return Player(
3848
id="01772c59-43f0-5d85-b913-c78e4e281452",
@@ -49,9 +59,9 @@ def existing_player():
4959
)
5060

5161

52-
def nonexistent_player():
62+
def nonexistent_player() -> Player:
5363
"""
54-
Creates a test stub for a nonexistent (new) Player.
64+
Creates a test fake for a nonexistent (new) Player.
5565
No id is provided; the server generates a UUID on creation.
5666
"""
5767
return Player(
@@ -67,9 +77,9 @@ def nonexistent_player():
6777
)
6878

6979

70-
def unknown_player():
80+
def unknown_player() -> Player:
7181
"""
72-
Creates a test stub for an unknown Player (valid UUID format, not in database).
82+
Creates a test fake for an unknown Player (valid UUID format, not in database).
7383
"""
7484
return Player(
7585
id="00000000-0000-0000-0000-000000000000",

tests/test_main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from uuid import UUID
2020

21-
from tests.player_stub import (
21+
from tests.player_fake import (
2222
existing_player,
2323
nonexistent_player,
2424
unknown_player,
@@ -92,8 +92,8 @@ def test_request_get_players_response_body_each_player_has_uuid(client):
9292
# GET /players/{player_id} -----------------------------------------------------
9393

9494

95-
def test_request_get_player_id_nonexistent_response_status_not_found(client):
96-
"""GET /players/{player_id} with nonexistent UUID returns 404 Not Found"""
95+
def test_request_get_player_id_unknown_response_status_not_found(client):
96+
"""GET /players/{player_id} with unknown UUID returns 404 Not Found"""
9797
# Arrange
9898
player_id = unknown_player().id
9999
# Act

0 commit comments

Comments
 (0)