test: apply evidence-based live checks without hiding regressions

This commit is contained in:
2026-09-09 02:40:13 -04:00
parent 16fa0ca474
commit 73008ad7d5
9 changed files with 2350 additions and 1359 deletions
+44
View File
@@ -997,3 +997,47 @@ class TestCrossFieldInvariants:
)
client = GatewayClient.from_settings(settings)
assert client is not None
async def test_flat_legacy_keys_assemble_without_source_timeout_or_network():
"""完整合成 env 验证平铺回落,不借真实配置或 Redis/PG。"""
env = dict(_BASE_ENV)
del env["LLM__QWEN__1__TIMEOUT_S"]
env.update({"LLM_TIMEOUT": "317", "LLM_TTFT_TIMEOUT": "41", "LLM_INTER_TOKEN_TIMEOUT": "19"})
settings = GatewaySettings.from_env("LLM", env=env)
assert settings.sources[0].timeout_s == 317
assert settings.sources[0].ttft_timeout_s == 41
assert settings.sources[0].inter_token_timeout_s == 19
assert settings.retry.max_attempts == 3
client = GatewayClient.from_settings(settings)
try:
assert client._transport._clients == {}
finally:
await client.aclose()
@pytest.mark.parametrize("model", ["MiniMax-M2.7", "MiniMax-M3"])
def test_live_assembly_rejection_is_local_only(model):
"""M2.7 NONE 与 M3 AUTO 的旧 live 装配断言离线执行。"""
env = _env(**{"LLM__QWEN__1__MODEL": model})
settings = GatewaySettings.from_env("LLM", env=env)
source = dataclasses.replace(
settings.sources[0], provider="minimax", enable_thinking=model == "MiniMax-M3"
)
with pytest.raises(ValueError, match=model):
GatewayClient.from_settings(dataclasses.replace(settings, sources=(source,)))
def test_live_unknown_wire_assembly_is_local_only():
"""L9 明确全 None profile,不从当前默认注册表猜未知形态。"""
mystery = ProviderProfile(
name="mystery",
thinking=ThinkingWire(off=None, on_base=None, effort_key=None),
strip_think_tags=False,
)
settings = GatewaySettings.from_env("LLM", env=_BASE_ENV)
source = dataclasses.replace(settings.sources[0], provider="mystery", enable_thinking=False)
with pytest.raises(ValueError, match="register_provider"):
GatewayClient.from_settings(
dataclasses.replace(settings, sources=(source,)), registry=register_provider(mystery)
)