mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-12 03:48:56 +00:00
* test: move the unit half of 126 mixed legacy files into tests/unit * test: restore litellm globals that moved tests set * test: finalize migration test cleanup * test: restore original bodies of moved legacy tests The move into tests/unit had rewritten 612 test bodies, and some of the rewrites dropped assertions. Each moved test now carries its original body from the legacy file, with only the imports, helpers, fake provider credentials and monkeypatched env it needs to run under tests/unit test_timeout_streaming goes back to tests/local_testing because it needs the fake OpenAI endpoint server. The image payload fixture moves with its only user, and two tests that leaked global state (a registered model cost entry and queued logging tasks) are now isolated * test: drop module imports shadowed by restored local imports * test: assert on LiteLLM output in no-assertion moved tests and isolate leaks Twenty no-assertion candidates get one assertion on the value LiteLLM returns, with the original lines unchanged. Four tests go back to their legacy files because they only check types or imports, write into the working directory, or cannot assert without a body change Two moved tests leaked globals into later tests in the same worker, so monkeypatch fixtures now restore the retry-after header parser and the end user cost tracking flags * test: drain queued logging tasks before the Phoenix span test The moved Phoenix test counted spans from logging tasks that earlier tests had queued, so the drain fixture moves to tests/unit/conftest.py and both it and the Datadog batch test use it. test_factory_function goes back to its legacy file because its returned wrapper calls the real Assistants API and cannot be asserted on without a body change --------- Co-authored-by: yuneng <yuneng@berri.ai>
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
"""
|
|
Tests for Lambda AI provider integration
|
|
"""
|
|
|
|
import os
|
|
from unittest import mock
|
|
|
|
import pytest
|
|
|
|
import litellm
|
|
from litellm.llms.lambda_ai.chat.transformation import LambdaAIChatConfig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_lambda_ai_completion_call():
|
|
"""Test completion call with Lambda AI provider (requires LAMBDA_API_KEY)"""
|
|
# Skip if no API key is available
|
|
if not os.getenv("LAMBDA_API_KEY"):
|
|
pytest.skip("LAMBDA_API_KEY not set")
|
|
|
|
try:
|
|
response = await litellm.acompletion(
|
|
model="lambda_ai/llama3.1-8b-instruct",
|
|
messages=[{"role": "user", "content": "Hello, this is a test"}],
|
|
max_tokens=10,
|
|
)
|
|
assert response.choices[0].message.content
|
|
assert response.model
|
|
assert response.usage
|
|
except Exception as e:
|
|
# If the API key is invalid or there's a network issue, that's okay
|
|
# The important thing is that the provider was recognized
|
|
if "lambda_ai" not in str(e) and "provider" not in str(e).lower():
|
|
# Re-raise if it's not a provider-related error
|
|
raise
|
|
|
|
|