feat: Better structure, add tests

This commit is contained in:
2026-05-09 17:38:37 +03:00
parent 3750804145
commit 827ec85907
9 changed files with 913 additions and 157 deletions
+32
View File
@@ -0,0 +1,32 @@
from __future__ import annotations
from config import AppSettings, as_public_dict
def test_app_settings_load_from_toml_and_masks_api_key(tmp_path) -> None:
config_path = tmp_path / "config.toml"
config_path.write_text(
"""
[llm]
model = "test-model"
api_key = "super-secret"
[game]
hard_mode_rotation_interval = 3
blocked_response_text = "blocked"
password_words = [
"w01", "w02", "w03", "w04", "w05",
"w06", "w07", "w08", "w09", "w10",
"w11", "w12", "w13", "w14", "w15",
"w16", "w17", "w18", "w19", "w20",
]
""".strip(),
encoding="utf-8",
)
settings = AppSettings.from_toml(config_path)
public_data = as_public_dict(settings)
assert settings.llm.model == "test-model"
assert settings.game.hard_mode_rotation_interval == 3
assert public_data["llm"]["api_key"] == "***"