mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
feat(combos): add Combos & Synergies detection, chip-style UI with dual hover; JSON persistence and headless honoring; stage ordering; docs and tests; bump to v2.2.1
This commit is contained in:
parent
cc16c6f13a
commit
6c48fb3437
38 changed files with 2042 additions and 131 deletions
58
code/tests/test_diagnostics_combos_api.py
Normal file
58
code/tests/test_diagnostics_combos_api.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
|
||||
def _write_json(path: Path, obj: dict):
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(obj), encoding="utf-8")
|
||||
|
||||
|
||||
def test_diagnostics_combos_endpoint(tmp_path: Path, monkeypatch):
|
||||
# Enable diagnostics
|
||||
monkeypatch.setenv("SHOW_DIAGNOSTICS", "1")
|
||||
|
||||
# Lazy import app after env set
|
||||
import importlib
|
||||
import code.web.app as app_module
|
||||
importlib.reload(app_module)
|
||||
|
||||
client = TestClient(app_module.app)
|
||||
|
||||
cpath = tmp_path / "config/card_lists/combos.json"
|
||||
spath = tmp_path / "config/card_lists/synergies.json"
|
||||
_write_json(
|
||||
cpath,
|
||||
{
|
||||
"list_version": "0.1.0",
|
||||
"pairs": [
|
||||
{"a": "Thassa's Oracle", "b": "Demonic Consultation", "cheap_early": True, "setup_dependent": False}
|
||||
],
|
||||
},
|
||||
)
|
||||
_write_json(
|
||||
spath,
|
||||
{
|
||||
"list_version": "0.1.0",
|
||||
"pairs": [{"a": "Grave Pact", "b": "Phyrexian Altar"}],
|
||||
},
|
||||
)
|
||||
|
||||
payload = {
|
||||
"names": ["Thassa’s Oracle", "Demonic Consultation", "Grave Pact", "Phyrexian Altar"],
|
||||
"combos_path": str(cpath),
|
||||
"synergies_path": str(spath),
|
||||
}
|
||||
resp = client.post("/diagnostics/combos", json=payload)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert data["counts"]["combos"] == 1
|
||||
assert data["counts"]["synergies"] == 1
|
||||
assert data["versions"]["combos"] == "0.1.0"
|
||||
# Ensure flags are present from payload
|
||||
c = data["combos"][0]
|
||||
assert c.get("cheap_early") is True
|
||||
assert c.get("setup_dependent") is False
|
||||
Loading…
Add table
Add a link
Reference in a new issue