mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-16 23:50:12 +01:00
build(ci): harden preview perf gate
This commit is contained in:
parent
8e57588f40
commit
2888d97883
5 changed files with 65 additions and 1 deletions
20
code/tests/test_preview_perf_fetch_retry.py
Normal file
20
code/tests/test_preview_perf_fetch_retry.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from code.scripts import preview_perf_benchmark as perf
|
||||
|
||||
|
||||
def test_fetch_all_theme_slugs_retries(monkeypatch):
|
||||
calls = {"count": 0}
|
||||
|
||||
def fake_fetch(url): # type: ignore[override]
|
||||
calls["count"] += 1
|
||||
if calls["count"] == 1:
|
||||
raise RuntimeError("transient 500")
|
||||
assert url.endswith("offset=0")
|
||||
return {"items": [{"id": "alpha"}], "next_offset": None}
|
||||
|
||||
monkeypatch.setattr(perf, "_fetch_json", fake_fetch)
|
||||
monkeypatch.setattr(perf.time, "sleep", lambda *_args, **_kwargs: None)
|
||||
|
||||
slugs = perf.fetch_all_theme_slugs("http://example.com", page_limit=1)
|
||||
|
||||
assert slugs == ["alpha"]
|
||||
assert calls["count"] == 2
|
||||
Loading…
Add table
Add a link
Reference in a new issue