treefmt / nix fmt (pull_request) Successful in 6s
test ebook search / test-ebook-search (pull_request) Successful in 39s
pytest / pytest (pull_request) Successful in 40s
build_systems / build-brain (pull_request) Successful in 1m0s
build_systems / build-bob (pull_request) Successful in 1m2s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m33s
build_systems / build-jeeves (pull_request) Successful in 2m25s
test ebook search / test-ebook-search (push) Successful in 35s
build_systems / build-brain (push) Successful in 37s
build_systems / build-bob (push) Successful in 37s
build_systems / build-jeeves (push) Successful in 2m17s
treefmt / nix fmt (push) Successful in 5s
pytest / pytest (push) Successful in 29s
build_systems / build-rhapsody-in-green (push) Successful in 49s
- implement FastAPI and HTMX lobby and game interfaces - support up to four human and AI-controlled players - add configurable rules, victory conditions, and expansion modules - support validated JSON cards, patrons, objectives, and outposts
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from python.gems.content import ContentPackError, content_pack_schema, parse_content_pack
|
|
|
|
|
|
def test_schema_uses_neutral_patrons_name() -> None:
|
|
assert "patrons" in content_pack_schema()["properties"]
|
|
assert "governors" not in content_pack_schema()["properties"]
|
|
|
|
|
|
def test_governors_is_accepted_as_input_alias(content_pack) -> None:
|
|
data = content_pack.model_dump(mode="json")
|
|
data["governors"] = data.pop("patrons")
|
|
parsed = parse_content_pack(json.dumps(data))
|
|
assert parsed.pack.patrons[0].id == "patron_one"
|
|
|
|
|
|
def test_both_patron_names_are_rejected(content_pack) -> None:
|
|
data = content_pack.model_dump(mode="json")
|
|
data["governors"] = data["patrons"]
|
|
with pytest.raises(ContentPackError, match="use patrons or governors"):
|
|
parse_content_pack(json.dumps(data))
|
|
|
|
|
|
def test_standard_symbols_are_normalized_in_canonical_pack_data(content_pack) -> None:
|
|
data = content_pack.model_dump(mode="json")
|
|
data["resources"][0].update(label="Onyx", symbol="B")
|
|
data["wild_resource"].update(label="Gold", symbol="Au")
|
|
|
|
parsed = parse_content_pack(json.dumps(data))
|
|
canonical = json.loads(parsed.canonical_json)
|
|
|
|
assert canonical["resources"][0]["symbol"] == "O"
|
|
assert canonical["wild_resource"]["symbol"] == "G"
|
|
|
|
|
|
def test_unknown_resource_reference_is_rejected(content_pack) -> None:
|
|
data = content_pack.model_dump(mode="json")
|
|
data["cards"][0]["cost"] = {"missing": 1}
|
|
with pytest.raises(ContentPackError, match="unknown cost resource"):
|
|
parse_content_pack(json.dumps(data))
|