fix: make h2 patch repair failures diagnosable
This commit is contained in:
@@ -150,6 +150,15 @@ class FakeResp:
|
||||
def read(self):
|
||||
return json.dumps(self.payload).encode()
|
||||
|
||||
class EmptyResp:
|
||||
headers = {"Content-Type": "application/json"}
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __exit__(self, exc_type, exc, tb):
|
||||
return False
|
||||
def read(self):
|
||||
return b""
|
||||
|
||||
def fake_urlopen(req, timeout):
|
||||
seen.append((req.full_url, dict(req.header_items()), json.loads(req.data.decode())))
|
||||
if req.full_url.endswith("/v1/responses"):
|
||||
@@ -207,6 +216,14 @@ for fn, bad in (
|
||||
assert exc.code == 2, exc.code
|
||||
else:
|
||||
raise AssertionError(f"{fn.__name__} accepted malformed provider payload")
|
||||
|
||||
try:
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
mc.decode_provider_json(EmptyResp(), "openai-compatible")
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 2, exc.code
|
||||
else:
|
||||
raise AssertionError("empty provider response was accepted")
|
||||
print("ok")
|
||||
PY
|
||||
[[ $? -eq 0 ]] && pass "cloud/gateway provider responses parse real usage and reject malformed payloads" || fail "cloud/gateway provider parser coverage failed"
|
||||
|
||||
Reference in New Issue
Block a user