Files
tft/backend/tests/test_constants.py
2026-07-23 00:26:53 +02:00

43 lines
964 B
Python

import pytest
from tft.constants.loader import load_constants, validate
@pytest.fixture
def c():
return load_constants(17)
def test_loads_and_validates(c):
assert c["set"] == 17
def test_shop_odds_shape(c):
assert len(c["shop"]["odds"]) == c["xp"]["max_level"]
for row in c["shop"]["odds"]:
assert sum(row) == 100
def test_xp_reaches_max_level(c):
assert len(c["xp"]["to_next"]) == c["xp"]["max_level"] - 1
assert all(x > 0 for x in c["xp"]["to_next"])
def test_interest_and_streaks(c):
g = c["gold"]
assert g["interest_cap"] >= 1
streaks = g["streak_gold"]
assert streaks == sorted(streaks)
assert all(gold > 0 for _, gold in streaks)
def test_missing_set_raises():
with pytest.raises(FileNotFoundError):
load_constants(99)
def test_validation_catches_bad_odds(c):
c["shop"]["odds"][0] = [99, 0, 0, 0, 0]
with pytest.raises(ValueError, match="sum to 99"):
validate(c)