test(llm): 200 非 JSON 体→LLMError 补测试钉——T9 偏差4(实现已在 4725593,旧码 JSONDecodeError 靠路由层 except ValueError 兜底,新语义显式 502)就此闭 (审计 #91⑥) [vps] [no-doc]
This commit is contained in:
@@ -44,6 +44,18 @@ class TestHappyPath:
|
||||
assert out == {"a": 1}
|
||||
assert calls[0].headers["authorization"] == "Bearer sk-test"
|
||||
|
||||
def test_200_non_json_body_raises_llm_error(self):
|
||||
"""#91⑥(T9 偏差4 补钉): 200 但体非 JSON → LLMError(显式 502 语义),
|
||||
不再是 JSONDecodeError 裸抛靠路由层 except ValueError 兜底."""
|
||||
def h(request):
|
||||
calls.append(request)
|
||||
return httpx.Response(200, text="not json at all",
|
||||
headers={"Content-Type": "text/plain"})
|
||||
client, calls, _ = _make(h)
|
||||
from sanguo_api.llm import LLMError
|
||||
with pytest.raises(LLMError):
|
||||
asyncio.run(client.chat_json(MSGS))
|
||||
|
||||
|
||||
class TestRetry:
|
||||
def test_429_honors_retry_after_seconds(self):
|
||||
|
||||
Reference in New Issue
Block a user