mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-16 15:40:12 +01:00
Some checks failed
Editorial Lint / lint-editorial (push) Has been cancelled
- document random theme exclusions, perf guard tooling, and roadmap completion - tighten random reroll UX: strict theme persistence, throttle handling, export parity, diagnostics updates - add regression coverage for telemetry counters, multi-theme flows, and locked rerolls; refresh README and notes Tests: pytest -q (fast random + telemetry suites)
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import json
|
|
import os
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
def _new_client():
|
|
os.environ['RANDOM_MODES'] = '1'
|
|
os.environ['RANDOM_UI'] = '1'
|
|
os.environ['CSV_FILES_DIR'] = os.path.join('csv_files','testdata')
|
|
from web.app import app
|
|
return TestClient(app)
|
|
|
|
|
|
def test_reroll_keeps_commander():
|
|
client = _new_client()
|
|
# Initial random build (api path) to get commander + seed
|
|
r1 = client.post('/api/random_reroll', json={})
|
|
assert r1.status_code == 200
|
|
data1 = r1.json()
|
|
commander = data1['commander']
|
|
seed = data1['seed']
|
|
|
|
# First reroll with commander lock
|
|
headers = {'Content-Type': 'application/json'}
|
|
body = json.dumps({'seed': seed, 'commander': commander, 'mode': 'reroll_same_commander'})
|
|
r2 = client.post('/hx/random_reroll', content=body, headers=headers)
|
|
assert r2.status_code == 200
|
|
html1 = r2.text
|
|
assert commander in html1
|
|
|
|
# Second reroll should keep same commander (seed increments so prior +1 used on server)
|
|
body2 = json.dumps({'seed': seed + 1, 'commander': commander, 'mode': 'reroll_same_commander'})
|
|
r3 = client.post('/hx/random_reroll', content=body2, headers=headers)
|
|
assert r3.status_code == 200
|
|
html2 = r3.text
|
|
assert commander in html2
|