fix: don't label a FINAL playoff card as CLINCHER — those stakes belong to the next game
seriesStatus updates with the just-played game's win, so once a card goes FINAL the is_clincher / is_game7 / is_pivotal predicates point at the upcoming game. Gate the stake badge, stake blurb, and elimination_count tally on a non-FINAL gameState so a completed Game 3 that left the series 3-0 reads "Flyers lead 3-0" instead of "Flyers can close it out — Game 3." Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,22 @@ class TestSeriesBlurb:
|
||||
assert "1" in blurb
|
||||
assert "Game 3" in blurb
|
||||
|
||||
def test_final_clincher_falls_through_to_leader_blurb(self):
|
||||
# Post-game seriesStatus (3-0) would trigger the clincher branch, but
|
||||
# the FINAL card is already decided — that stake belongs to Game 4.
|
||||
game = make_playoff_game(
|
||||
top_wins=3,
|
||||
bottom_wins=0,
|
||||
top_abbrev="PHI",
|
||||
bottom_abbrev="PIT",
|
||||
top_is_home=True,
|
||||
game_state="OFF",
|
||||
)
|
||||
blurb = series_blurb(game)
|
||||
assert "close it out" not in blurb
|
||||
assert "lead" in blurb
|
||||
assert "3‑0" in blurb
|
||||
|
||||
|
||||
class TestSeriesBadges:
|
||||
def test_round_1_always_first(self):
|
||||
@@ -135,6 +151,12 @@ class TestSeriesBadges:
|
||||
badges = series_badges(make_playoff_game(top_wins=0, bottom_wins=0))
|
||||
assert badges == ["R1"]
|
||||
|
||||
def test_no_stake_badge_on_final(self):
|
||||
# Post-game seriesStatus shows is_clincher true, but CLINCHER refers to
|
||||
# the upcoming Game 4, not the completed card.
|
||||
game = make_playoff_game(top_wins=3, bottom_wins=0, game_state="OFF")
|
||||
assert series_badges(game) == ["R1"]
|
||||
|
||||
|
||||
class TestSeriesSummary:
|
||||
def test_opener_summary(self):
|
||||
@@ -285,3 +307,25 @@ class TestTodayMeta:
|
||||
games = [make_playoff_game(round_num=4, series_letter="P")]
|
||||
meta = today_meta(games)
|
||||
assert meta["round_label"] == "Stanley Cup Final"
|
||||
|
||||
def test_does_not_count_final_games_as_elimination(self):
|
||||
games = [
|
||||
make_playoff_game(
|
||||
top_wins=3, bottom_wins=0, series_letter="A", game_state="OFF"
|
||||
),
|
||||
make_playoff_game(
|
||||
top_wins=3, bottom_wins=1, series_letter="B", game_state="LIVE"
|
||||
),
|
||||
]
|
||||
meta = today_meta(games)
|
||||
# Only the LIVE card counts; the FINAL card describes a completed game.
|
||||
assert meta["elimination_count"] == 1
|
||||
|
||||
def test_does_not_count_final_game7(self):
|
||||
games = [
|
||||
make_playoff_game(
|
||||
top_wins=3, bottom_wins=3, series_letter="A", game_state="OFF"
|
||||
)
|
||||
]
|
||||
meta = today_meta(games)
|
||||
assert meta["game7_count"] == 0
|
||||
|
||||
Reference in New Issue
Block a user