test(passthrough): drop the fastapi import from the normalization tests

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yucheng 2026-09-25 18:30:14 +00:00
parent f7c157083a
commit 9045a2df9e

View file

@ -166,25 +166,21 @@ def test_variants_of_one_failure_share_a_normalized_error(messages: tuple[Except
def test_normalize_error_passthrough_prefix_wins_over_upstream_body_text() -> None:
from fastapi import HTTPException
for detail in (
'Upstream passthrough request failed with status 400: {"error": {"message": "no deployments available for this model"}}',
'Upstream passthrough request failed with status 400: {"error": {"message": "max budget reached"}}',
):
exc = HTTPException(status_code=400, detail=detail)
exc = Exception(detail)
message = f"400: {detail}"
assert normalize_error(exc, "400", message) == "500_UPSTREAM_PASSTHROUGH", message
def test_normalize_error_passthrough_prefix_wins_over_quota_and_budget_wording() -> None:
from fastapi import HTTPException
detail = (
'Upstream passthrough request failed with status 429: {"error": {"message": '
'"You exceeded your current quota, please check your plan and billing details. Budget spent"}}'
)
exc = HTTPException(status_code=429, detail=detail)
exc = Exception(detail)
assert normalize_error(exc, "429", f"429: {detail}") == "500_UPSTREAM_PASSTHROUGH"