Files
life-echo/api/tests/test_settings_allowlist.py
Kevin 07979bfb09 feat(api): use Tencent ASR flash with 16k_zh_large and dev transcript logs
Replace CreateRecTask polling with recording-file flash API, add TENCENT_APP_ID,
remove server-side pydub slicing, and log ASR recognition text at INFO in development.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-25 11:28:22 +08:00

57 lines
1.3 KiB
Python

"""Settings 字段数量守卫:防止 env 反弹为巨型配置。"""
from app.core.config import Settings
ALLOWLIST_MAX_FIELDS = 23
EXPECTED_PREFIXES = (
"database_",
"redis_",
"celery_",
"app_",
"secret_",
"deepseek_",
"zhipu_",
"tencent_secret_",
"tencent_app_",
"wechat_pay_",
"alipay_",
"liblib_",
"internal_eval_",
)
def test_settings_field_count_within_allowlist() -> None:
assert len(Settings.model_fields) <= ALLOWLIST_MAX_FIELDS
def test_settings_has_only_secrets_and_bootstrap_fields() -> None:
for name in Settings.model_fields:
assert name.startswith(EXPECTED_PREFIXES), (
f"unexpected Settings field {name!r}; "
"non-secret deploy/product config belongs in config/*.toml"
)
def test_settings_has_no_product_tuning_field_names() -> None:
blocked = (
"chat_",
"memory_",
"eval_",
"story_",
"memoir_",
"agent_log_",
"enable_",
"otel_",
"log_",
"access_",
"refresh_",
"mock_",
"tencent_sms_",
"tencent_cos_",
"api_cors_",
"alembic_",
)
for name in Settings.model_fields:
assert not any(name.startswith(p) for p in blocked)