refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env) 统一错误契约 Auth 与事务边界 Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client 可观测性(OpenTelemetry + LGTM)
This commit is contained in:
33
api/tests/test_app_config_loader.py
Normal file
33
api/tests/test_app_config_loader.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""TOML configuration loader tests."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from app.core.app_config_loader import load_app_config
|
||||
|
||||
|
||||
FIXTURES = Path(__file__).resolve().parent / "fixtures" / "config"
|
||||
|
||||
|
||||
def test_load_default_only() -> None:
|
||||
cfg = load_app_config("development", config_dir=FIXTURES / "minimal")
|
||||
assert cfg.chat.interview_persona == "default"
|
||||
assert cfg.deploy.enable_tts is True
|
||||
|
||||
|
||||
def test_staging_overlay_merges_chat_section() -> None:
|
||||
cfg = load_app_config("staging", config_dir=FIXTURES / "merge")
|
||||
assert cfg.chat.interview_persona == "staging_persona"
|
||||
assert cfg.chat.interview_temperature == 0.93
|
||||
assert cfg.deploy.mock_sms_login_enabled is True
|
||||
|
||||
|
||||
def test_unknown_top_level_key_rejected(tmp_path: Path) -> None:
|
||||
bad = tmp_path / "default.toml"
|
||||
bad.write_text(
|
||||
'[deploy]\nenable_tts = true\n\n[typo_section]\nfoo = 1\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
with pytest.raises(Exception):
|
||||
load_app_config("development", config_dir=tmp_path)
|
||||
Reference in New Issue
Block a user