From f9c25c56321c96a50ccd5dc376cfd41991bcf409 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 10 Apr 2026 21:01:33 -0500 Subject: [PATCH] fix: address review feedback on card-of-the-week PR (#212) - Add `= None` default to `Optional[str]` field in CardOfTheWeekResponse (Pydantic v1 convention: Optional fields should have explicit None default) - Remove unused `_PACK_COUNTER` dead variable from test module - Remove unused `cardset` parameter from `_make_pack_type` helper and update all 6 call sites Co-Authored-By: Claude Sonnet 4.6 --- app/routers_v2/featured.py | 4 +++- tests/test_card_of_the_week.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/routers_v2/featured.py b/app/routers_v2/featured.py index ee7563b..5e97a33 100644 --- a/app/routers_v2/featured.py +++ b/app/routers_v2/featured.py @@ -50,7 +50,9 @@ class CardOfTheWeekResponse(pydantic.BaseModel): rating: int card_image_url: str cardset_name: str - card_created_at: Optional[str] # ISO-8601 string; None when pack has no open_time + card_created_at: Optional[str] = ( + None # ISO-8601 string; None when pack has no open_time + ) @router.get( diff --git a/tests/test_card_of_the_week.py b/tests/test_card_of_the_week.py index 246261d..9b7a143 100644 --- a/tests/test_card_of_the_week.py +++ b/tests/test_card_of_the_week.py @@ -157,7 +157,6 @@ def cotw_client(cotw_db): _RARITY_COUNTER = [0] _TEAM_COUNTER = [0] -_PACK_COUNTER = [0] def _make_rarity(name: str = "Common") -> Rarity: @@ -208,7 +207,7 @@ def _make_team(is_ai: bool = False, suffix: str = "") -> Team: ) -def _make_pack_type(cardset: Cardset) -> PackType: +def _make_pack_type() -> PackType: return PackType.create( name="COTW Pack Type", card_count=5, @@ -268,7 +267,7 @@ def test_happy_path_single_eligible_card(cotw_db, cotw_client): image="https://s3.example.com/happy.png", ) team = _make_team() - pt = _make_pack_type(cardset) + pt = _make_pack_type() pack = _make_pack(team, pt, open_time=_recent(1)) card = _make_card(player, team, pack, value=85) @@ -301,7 +300,7 @@ def test_empty_window_returns_404(cotw_db, cotw_client): cardset = _make_cardset("COTW Old Set") player = _make_player(rarity, cardset, name="Old Timer") team = _make_team() - pt = _make_pack_type(cardset) + pt = _make_pack_type() pack = _make_pack(team, pt, open_time=_old(14)) _make_card(player, team, pack, value=70) @@ -323,7 +322,7 @@ def test_ai_team_excluded_by_default(cotw_db, cotw_client): """ rarity = _make_rarity("MVP") cardset = _make_cardset("AI Excl Set") - pt = _make_pack_type(cardset) + pt = _make_pack_type() ai_team = _make_team(is_ai=True, suffix="AI") human_team = _make_team(is_ai=False, suffix="HU") @@ -363,7 +362,7 @@ def test_include_ai_true_includes_ai_team_card(cotw_db, cotw_client): """ rarity = _make_rarity("MVP") cardset = _make_cardset("AI Incl Set") - pt = _make_pack_type(cardset) + pt = _make_pack_type() ai_team = _make_team(is_ai=True, suffix="AI2") human_team = _make_team(is_ai=False, suffix="HU2") @@ -401,7 +400,7 @@ def test_tiebreak_highest_rating_wins(cotw_db, cotw_client): """ rarity = _make_rarity("HoF") cardset = _make_cardset("Tiebreak Rating Set") - pt = _make_pack_type(cardset) + pt = _make_pack_type() team = _make_team() open_time = _recent(2) @@ -439,7 +438,7 @@ def test_tiebreak_same_rating_newest_pack_wins(cotw_db, cotw_client): """ rarity = _make_rarity("All-Star") cardset = _make_cardset("Tiebreak Newest Set") - pt = _make_pack_type(cardset) + pt = _make_pack_type() team = _make_team() p_old = _make_player(