mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
feat(themes): whitelist governance, synergy cap, docs + tests; feat(random): laid roadwork for random implementation, testing in headless confirmed
This commit is contained in:
parent
03e839fb87
commit
16261bbf09
34 changed files with 12594 additions and 23 deletions
25
code/tests/test_random_full_build_api.py
Normal file
25
code/tests/test_random_full_build_api.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import os
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
|
||||
def test_random_full_build_api_returns_deck_and_permalink(monkeypatch):
|
||||
# Enable Random Modes and use tiny dataset
|
||||
monkeypatch.setenv("RANDOM_MODES", "1")
|
||||
monkeypatch.setenv("CSV_FILES_DIR", os.path.join("csv_files", "testdata"))
|
||||
|
||||
app_module = importlib.import_module('code.web.app')
|
||||
client = TestClient(app_module.app)
|
||||
|
||||
payload = {"seed": 4242, "theme": "Goblin Kindred"}
|
||||
r = client.post('/api/random_full_build', json=payload)
|
||||
assert r.status_code == 200
|
||||
data = r.json()
|
||||
assert data["seed"] == 4242
|
||||
assert isinstance(data.get("commander"), str) and data["commander"]
|
||||
assert isinstance(data.get("decklist"), list)
|
||||
# Permalink present and shaped like /build/from?state=...
|
||||
assert data.get("permalink")
|
||||
assert "/build/from?state=" in data["permalink"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue