mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-23 20:06:17 +01:00
Serve no history for demo budget runs
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f0f14ebf49
commit
9062fa8c10
@ -197,7 +197,13 @@ def build_budget_snapshot(*, demo: bool = False) -> dict[str, Any]:
|
|||||||
{"pid": game.pid, "name": game.name} for game in session.games
|
{"pid": game.pid, "name": game.name} for game in session.games
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"history": [
|
# Demo runs have no history by design — HistoryWriter skips them, for
|
||||||
|
# the same reason they get their own state file and log. Serving the
|
||||||
|
# production days here would plot real 8-hour days against the demo's
|
||||||
|
# 60-second budget line, painting every one of them over-budget.
|
||||||
|
"history": []
|
||||||
|
if demo
|
||||||
|
else [
|
||||||
{"day": day.day, "seconds": round(day.seconds, 1)}
|
{"day": day.day, "seconds": round(day.seconds, 1)}
|
||||||
for day in load_history(_HISTORY_DAYS)
|
for day in load_history(_HISTORY_DAYS)
|
||||||
],
|
],
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class TestBuildBudgetSnapshot:
|
|||||||
patch.object(view, "last_verdict", return_value=kwargs["session"]),
|
patch.object(view, "last_verdict", return_value=kwargs["session"]),
|
||||||
patch.object(view, "mounted_targets", return_value=set()),
|
patch.object(view, "mounted_targets", return_value=set()),
|
||||||
):
|
):
|
||||||
return build_budget_snapshot()
|
return build_budget_snapshot(demo=bool(kwargs.get("demo", False)))
|
||||||
|
|
||||||
def test_reports_a_readable_day(self) -> None:
|
def test_reports_a_readable_day(self) -> None:
|
||||||
snapshot = self._snapshot()
|
snapshot = self._snapshot()
|
||||||
@ -180,6 +180,15 @@ class TestBuildBudgetSnapshot:
|
|||||||
snapshot = self._snapshot()
|
snapshot = self._snapshot()
|
||||||
assert snapshot["history"] == [{"day": "2026-08-27", "seconds": 1.5}]
|
assert snapshot["history"] == [{"day": "2026-08-27", "seconds": 1.5}]
|
||||||
|
|
||||||
|
def test_demo_runs_serve_no_history(self) -> None:
|
||||||
|
"""Production days must not be plotted against the 60-second budget."""
|
||||||
|
day = HistoryDay(day="2026-08-28", seconds=28800.0)
|
||||||
|
with patch.object(view, "load_history", return_value=[day]) as load:
|
||||||
|
snapshot = self._snapshot(demo=True)
|
||||||
|
assert snapshot["history"] == []
|
||||||
|
assert snapshot["rules"]["demo"] is True
|
||||||
|
load.assert_not_called()
|
||||||
|
|
||||||
def test_leaks_no_secret(self) -> None:
|
def test_leaks_no_secret(self) -> None:
|
||||||
"""The API key must never cross the HTTP boundary."""
|
"""The API key must never cross the HTTP boundary."""
|
||||||
with patch.object(Config, "load", return_value=Config(steam_api_key="SEKRET")):
|
with patch.object(Config, "load", return_value=Config(steam_api_key="SEKRET")):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user