mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2026-04-06 21:15:20 +02:00
test-cleanup: fix 21 failures, prune stale tests, consolidate fragmented files (#66)
Some checks are pending
CI / build (push) Waiting to run
Some checks are pending
CI / build (push) Waiting to run
* test-cleanup: fix 21 failures, prune stale tests, consolidate fragmented files * test-cleanup: remove permanently-skipped M4/perf tests, fix pydantic ConfigDict warning * docs: update changelog and release notes for test-cleanup changes * ci: fix editorial governance workflow stale test file reference
This commit is contained in:
parent
32157179f9
commit
46637cf27f
34 changed files with 5329 additions and 2202 deletions
|
|
@ -52,3 +52,67 @@ def test_splash_off_color_penalty_applied():
|
|||
splash = next((c for c in cards if c["name"] == "CardSplash"), None)
|
||||
assert splash is not None
|
||||
assert any(r.startswith("splash_off_color_penalty") for r in splash["reasons"])
|
||||
|
||||
|
||||
def test_role_saturation_penalty_applies(monkeypatch):
|
||||
cards = []
|
||||
for i in range(30):
|
||||
cards.append({"name": f"Payoff{i}", "color_identity": "G", "tags": ["testtheme"], "mana_cost": "1G", "rarity": "common", "color_identity_list": ["G"], "pip_colors": ["G"]})
|
||||
monkeypatch.setattr("code.web.services.sampling.get_tag_pool", lambda tag: cards)
|
||||
monkeypatch.setattr("code.web.services.sampling.maybe_build_index", lambda: None)
|
||||
monkeypatch.setattr("code.web.services.sampling.lookup_commander", lambda name: None)
|
||||
chosen = sampling.sample_real_cards_for_theme(theme="testtheme", limit=12, colors_filter=None, synergies=["testtheme"], commander=None)
|
||||
penalized = [c for c in chosen if any(r.startswith("role_saturation_penalty") for r in c.get("reasons", []))]
|
||||
assert penalized, "Expected at least one card to receive role_saturation_penalty"
|
||||
|
||||
|
||||
def test_adaptive_splash_penalty_scaling(monkeypatch):
|
||||
theme = "__AdaptiveSplashTest__"
|
||||
commander_name = "Test Commander"
|
||||
commander_tags = [theme, "Value", "ETB"]
|
||||
commander_entry = {
|
||||
"name": commander_name,
|
||||
"color_identity": "WUBR",
|
||||
"tags": commander_tags,
|
||||
"mana_cost": "WUBR",
|
||||
"rarity": "mythic",
|
||||
"color_identity_list": list("WUBR"),
|
||||
"pip_colors": list("WUBR"),
|
||||
}
|
||||
pool = [commander_entry]
|
||||
|
||||
def add_card(name: str, color_identity: str, tags: list):
|
||||
pool.append({
|
||||
"name": name,
|
||||
"color_identity": color_identity,
|
||||
"tags": tags,
|
||||
"mana_cost": "1G",
|
||||
"rarity": "uncommon",
|
||||
"color_identity_list": list(color_identity),
|
||||
"pip_colors": [c for c in "1G" if c in {"W", "U", "B", "R", "G"}],
|
||||
})
|
||||
|
||||
add_card("On Color Card", "WUB", [theme, "ETB"])
|
||||
add_card("Splash Card", "WUBG", [theme, "ETB", "Synergy"])
|
||||
|
||||
from code.web.services import card_index as ci
|
||||
monkeypatch.setattr(ci, "lookup_commander", lambda name: commander_entry if name == commander_name else None)
|
||||
monkeypatch.setattr(ci, "maybe_build_index", lambda: None)
|
||||
monkeypatch.setattr(ci, "get_tag_pool", lambda tag: pool if tag == theme else [])
|
||||
monkeypatch.setattr(sampling, "maybe_build_index", lambda: None)
|
||||
monkeypatch.setattr(sampling, "get_tag_pool", lambda tag: pool if tag == theme else [])
|
||||
monkeypatch.setattr(sampling, "lookup_commander", lambda name: commander_entry if name == commander_name else None)
|
||||
monkeypatch.setattr(sampling, "SPLASH_ADAPTIVE_ENABLED", True)
|
||||
monkeypatch.setenv("SPLASH_ADAPTIVE", "1")
|
||||
monkeypatch.setenv("SPLASH_ADAPTIVE_SCALE", "1:1.0,2:1.0,3:1.0,4:0.5,5:0.25")
|
||||
|
||||
cards = sampling.sample_real_cards_for_theme(theme, 10, None, synergies=[theme, "ETB", "Synergy"], commander=commander_name)
|
||||
by_name = {c["name"]: c for c in cards}
|
||||
assert "Splash Card" in by_name, cards
|
||||
splash_reasons = [r for r in by_name["Splash Card"]["reasons"] if r.startswith("splash_off_color_penalty")]
|
||||
assert splash_reasons, by_name["Splash Card"]["reasons"]
|
||||
adaptive_reason = next(r for r in splash_reasons if r.startswith("splash_off_color_penalty_adaptive"))
|
||||
parts = adaptive_reason.split(":")
|
||||
assert parts[1] == "4"
|
||||
penalty_value = float(parts[2])
|
||||
assert abs(penalty_value - (-0.3 * 0.5)) < 1e-6
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue