test(spend): assert Anthropic envelope for Messages budget refusals (#49800)

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
devin-ai-integration[bot] 2026-11-03 06:10:08 +00:00 • committed by GitHub
parent 3da6029977
commit 408773bb69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -346,5 +346,15 @@ def test_a_broken_messages_stream_counts_toward_the_budget(gateway: Gateway) ->
_broken_messages_stream(gateway, model, key)
after: Final = _messages(gateway, model, key, streamed=False)
assert_budget_refusal(after)
assert after.status_code == 422, after.text
body: Final = JSON_OBJECT.validate_json(after.content)
error: Final = JSON_OBJECT.validate_python(body["error"])
assert body == {
"type": "error",
"error": {
"type": "invalid_request_error",
"message": error["message"],
"litellm_error_type": "budget_exceeded",
},
}, after.text
assert _rows(gateway, key, 2) == (metered, StatusRow(status="failure", spend=0.0))