Merge pull request #42107 from BerriAI/litellm_migrate_tests_p6

test(llms): migrate phase 6 provider unit tests to tests/unit
This commit is contained in:
yuneng-jiang 2026-09-20 03:12:59 -07:00 • committed by GitHub
commit 53ba9f389f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 21 additions and 43 deletions

View file

@ -1,19 +0,0 @@
import pytest
import litellm
from litellm.litellm_core_utils.llm_cost_calc.utils import CostCalculatorUtils
from litellm.llms.fal_ai.cost_calculator import cost_calculator
from litellm.types.utils import ImageObject, ImageResponse
@pytest.fixture(autouse=True)
def _use_local_model_cost_map(monkeypatch):
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
litellm.get_model_info.cache_clear()
yield
litellm.get_model_info.cache_clear()
def _image_response(num_images: int = 1) -> ImageResponse:
return ImageResponse(data=[ImageObject(url="https://example.com/img.png") for _ in range(num_images)])

View file

@ -5,6 +5,7 @@ Source: litellm/llms/chatgpt/responses/transformation.py
"""
import json
from collections.abc import Generator
from unittest.mock import MagicMock, patch
import httpx
@ -19,6 +20,15 @@ from litellm.types.utils import LlmProviders
from litellm.utils import ProviderConfigManager
@pytest.fixture
def local_model_cost_map(monkeypatch: pytest.MonkeyPatch) -> Generator[None, None, None]:
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
litellm.get_model_info.cache_clear()
yield
litellm.get_model_info.cache_clear()
class TestChatGPTResponsesAPITransformation:
@pytest.mark.parametrize(
"model_name",

View file

@ -78,27 +78,3 @@ def test_completion_datarobot_with_deployment():
except Exception as e:
pytest.fail(f"Error occurred: {e}")
def test_completion_datarobot_with_environment_variables():
"""Allow the test to run with environment variables if they are set for integrations."""
# If keys are not set, the test will be skipped
if os.environ.get("DATAROBOT_API_TOKEN") is None:
return
messages = [
{"role": "user", "content": "What's the weather like in San Francisco?"}
]
try:
response = completion(
model="datarobot/vertex_ai/gemini-1.5-flash-002",
messages=messages,
max_tokens=5,
clientId="custom-model",
)
print(response)
assert response["object"] == "chat.completion"
assert response["model"] == "gemini-1.5-flash-002"
assert len(response["choices"]) == 1
assert len(response["choices"][0]["message"]["content"]) > 0
except Exception as e:
pytest.fail(f"Error occurred: {e}")

View file

@ -1,3 +1,4 @@
from collections.abc import Generator
from datetime import datetime, timezone
from typing import Final
@ -7,6 +8,16 @@ import litellm
from litellm._internal_context import pinned_billing_time
from litellm.types.utils import ModelResponse, PromptTokensDetailsWrapper, Usage
@pytest.fixture
def local_model_cost_map(monkeypatch: pytest.MonkeyPatch) -> Generator[None, None, None]:
monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
litellm.get_model_info.cache_clear()
yield
litellm.get_model_info.cache_clear()
PEAK_MOMENTS: Final = (
pytest.param(datetime(2026, 9, 22, 8, 0, tzinfo=timezone.utc), id="tuesday-08:00"),
pytest.param(datetime(2026, 9, 25, 9, 59, tzinfo=timezone.utc), id="friday-09:59"),