33 lines
831 B
Python
33 lines
831 B
Python
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"] == "***"
|