mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
feat(random): multi-theme groundwork, locked reroll export parity, duplicate export fix, expanded diagnostics and test coverage
This commit is contained in:
parent
a029d430c5
commit
73685f22c8
39 changed files with 2671 additions and 271 deletions
45
code/tests/test_random_reroll_locked_artifacts.py
Normal file
45
code/tests/test_random_reroll_locked_artifacts.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import os
|
||||
import time
|
||||
from glob import glob
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def _client():
|
||||
os.environ['RANDOM_UI'] = '1'
|
||||
os.environ['RANDOM_MODES'] = '1'
|
||||
os.environ['CSV_FILES_DIR'] = os.path.join('csv_files','testdata')
|
||||
from web.app import app
|
||||
return TestClient(app)
|
||||
|
||||
|
||||
def _recent_files(pattern: str, since: float):
|
||||
out = []
|
||||
for p in glob(pattern):
|
||||
try:
|
||||
if os.path.getmtime(p) >= since:
|
||||
out.append(p)
|
||||
except Exception:
|
||||
pass
|
||||
return out
|
||||
|
||||
|
||||
def test_locked_reroll_generates_summary_and_compliance():
|
||||
c = _client()
|
||||
# First random build (api) to establish commander/seed
|
||||
r = c.post('/api/random_reroll', json={})
|
||||
assert r.status_code == 200, r.text
|
||||
data = r.json()
|
||||
commander = data['commander']
|
||||
seed = data['seed']
|
||||
|
||||
start = time.time()
|
||||
# Locked reroll via HTMX path (form style)
|
||||
form_body = f"seed={seed}&commander={commander}&mode=reroll_same_commander"
|
||||
r2 = c.post('/hx/random_reroll', data=form_body, headers={'Content-Type':'application/x-www-form-urlencoded'})
|
||||
assert r2.status_code == 200, r2.text
|
||||
|
||||
# Look for new sidecar/compliance created after start
|
||||
recent_summary = _recent_files('deck_files/*_*.summary.json', start)
|
||||
recent_compliance = _recent_files('deck_files/*_compliance.json', start)
|
||||
assert recent_summary, 'Expected at least one new summary json after locked reroll'
|
||||
assert recent_compliance, 'Expected at least one new compliance json after locked reroll'
|
||||
Loading…
Add table
Add a link
Reference in a new issue