feat(observe): 加 OBSERVE_* 配置与 observe_configured 门槛
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"""接口指标可观测(observe)单测:配置门槛 / 队列 / 中间件 / worker。
|
||||
|
||||
沿用仓库约定:TestClient + monkeypatch,绝不打真网络。observe 默认关(conftest 未设
|
||||
OBSERVE_*),需要开启的用例用 monkeypatch 改 settings 单例属性。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
|
||||
def test_observe_configured_requires_switch_and_creds(monkeypatch):
|
||||
# 开关开 + endpoint(默认 localhost)+ user + password 齐全 → True
|
||||
monkeypatch.setattr(settings, "OBSERVE_ENABLED", True)
|
||||
monkeypatch.setattr(settings, "OBSERVE_USER", "u")
|
||||
monkeypatch.setattr(settings, "OBSERVE_PASSWORD", "p")
|
||||
assert settings.observe_configured is True
|
||||
|
||||
# 缺密码 → False
|
||||
monkeypatch.setattr(settings, "OBSERVE_PASSWORD", "")
|
||||
assert settings.observe_configured is False
|
||||
|
||||
# 开关关 → False(即便凭证齐全)
|
||||
monkeypatch.setattr(settings, "OBSERVE_PASSWORD", "p")
|
||||
monkeypatch.setattr(settings, "OBSERVE_ENABLED", False)
|
||||
assert settings.observe_configured is False
|
||||
Reference in New Issue
Block a user