mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-26 06:03:19 +00:00
test(llms): cover malformed provider response guards
Exercise the independent error and response-shape checks.
This commit is contained in:
parent
4009807017
commit
afeff77329
2 changed files with 13 additions and 2 deletions
|
|
@ -837,6 +837,7 @@ def _run_transform_response(response_body: dict) -> ModelResponse:
|
|||
{},
|
||||
{"error": {"message": "upstream broke"}},
|
||||
{"choices": None},
|
||||
{"choices": "not-a-list"},
|
||||
{"choices": []},
|
||||
{"choices": [{}]},
|
||||
{"choices": [{"message": {}}]},
|
||||
|
|
|
|||
|
|
@ -21,7 +21,14 @@ from litellm.types.utils import Message, ModelResponse, ModelResponseStream
|
|||
|
||||
|
||||
class TestOllamaConfig:
|
||||
@pytest.mark.parametrize("body", [{}, {"error": {"message": "upstream broke"}}])
|
||||
@pytest.mark.parametrize(
|
||||
"body",
|
||||
[
|
||||
{},
|
||||
{"error": {"message": "upstream broke"}},
|
||||
{"response": "", "error": {"message": "upstream broke"}},
|
||||
],
|
||||
)
|
||||
def test_transform_response_rejects_payload_without_completion(self, body):
|
||||
raw_response = MagicMock()
|
||||
raw_response.json.return_value = body
|
||||
|
|
@ -620,7 +627,10 @@ class TestOllamaConfig:
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
"response_body",
|
||||
[pytest.param({}, id="missing-response"), pytest.param({"error": {"message": "upstream broke"}}, id="error")],
|
||||
[
|
||||
pytest.param({}, id="missing-response"),
|
||||
pytest.param({"response": "", "error": {"message": "upstream broke"}}, id="error"),
|
||||
],
|
||||
)
|
||||
def test_completion_with_invalid_success_reply_raises_api_connection_error(
|
||||
respx_mock: respx.MockRouter, response_body: dict[str, object]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue