mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
* fix(spend): return 400 from /spend/calculate for a model with no pricing row Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(spend): assert error type and param for unpriced /spend/calculate Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(spend): move the repro to tests/integration Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: alias ModelNotMappedError re-export to satisfy F401 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(utils): raise ModelNotMappedError only when the pricing row is missing Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: kerry <kerry@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
20 lines
896 B
Python
20 lines
896 B
Python
import uuid
|
|
from typing import Final
|
|
|
|
import pytest
|
|
from integration._support.client import JSON_OBJECT, Gateway, object_value, string_value
|
|
|
|
|
|
@pytest.mark.covers("quota_management.spend_tracking.spend_calculate.rejects_unpriced_model")
|
|
def test_spend_calculate_rejects_unpriced_model_with_400(gateway: Gateway) -> None:
|
|
model: Final = f"openrouter/integration-unpriced-{uuid.uuid4().hex}"
|
|
response: Final = gateway.request(
|
|
"POST",
|
|
"/spend/calculate",
|
|
{"model": model, "messages": [{"role": "user", "content": "price this request"}]},
|
|
)
|
|
assert response.status_code == 400, response.text
|
|
error: Final = object_value(JSON_OBJECT.validate_json(response.text)["error"])
|
|
assert error["type"] == "invalid_request_error", response.text
|
|
assert error["param"] == "model", response.text
|
|
assert model in string_value(error["message"]), response.text
|