The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test: migrate phase 12 legacy llm provider tests to tests/unit
yunengef6237b9f2bc
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.pyindex 017e63ed1b8..fa91437964f 100644--- a/tests/unit/conftest.py+++ b/tests/unit/conftest.py@@ -1,6 +1,7 @@import osfrom typing import Final+import litellmimport pytestfrom pytest_socket import enable_socket, socket_allow_hosts@@ -9,6 +10,19 @@ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"LOOPBACK_HOSTS: Final = ["127.0.0.1", "::1"]+def local_model_cost_map(monkeypatch):+ original_model_cost = litellm.model_cost+ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")+ litellm.model_cost = litellm.get_model_cost_map(url="")+ litellm.get_model_info.cache_clear()+ try:+ yield+ finally:+ litellm.model_cost = original_model_cost+ litellm.get_model_info.cache_clear()++def _allow_loopback_only() -> None:socket_allow_hosts(LOOPBACK_HOSTS, allow_unix_socket=True)diff --git a/tests/test_litellm/llms/openrouter/responses/test_openrouter_responses_transformation.py b/tests/unit/llms/openrouter/responses/test_openrouter_responses_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/openrouter/responses/test_openrouter_responses_transformation.pyrename to tests/unit/llms/openrouter/responses/test_openrouter_responses_transformation.pydiff --git a/tests/test_litellm/llms/parallel_ai/test_parallel_ai_search.py b/tests/unit/llms/parallel_ai/test_parallel_ai_search.pysimilarity index 100%rename from tests/test_litellm/llms/parallel_ai/test_parallel_ai_search.pyrename to tests/unit/llms/parallel_ai/test_parallel_ai_search.pydiff --git a/tests/test_litellm/llms/parallel_ai/test_parallel_ai_search_gateway.py b/tests/unit/llms/parallel_ai/test_parallel_ai_search_gateway.pysimilarity index 100%rename from tests/test_litellm/llms/parallel_ai/test_parallel_ai_search_gateway.pyrename to tests/unit/llms/parallel_ai/test_parallel_ai_search_gateway.pydiff --git a/tests/test_litellm/llms/parasail/test_parasail.py b/tests/unit/llms/parasail/test_parasail.pysimilarity index 100%rename from tests/test_litellm/llms/parasail/test_parasail.pyrename to tests/unit/llms/parasail/test_parasail.pydiff --git a/tests/test_litellm/llms/perplexity/chat/test_perplexity_chat_transformation.py b/tests/unit/llms/perplexity/chat/test_perplexity_chat_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/perplexity/chat/test_perplexity_chat_transformation.pyrename to tests/unit/llms/perplexity/chat/test_perplexity_chat_transformation.pydiff --git a/tests/test_litellm/llms/perplexity/embedding/test_perplexity_embedding_transformation.py b/tests/unit/llms/perplexity/embedding/test_perplexity_embedding_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/perplexity/embedding/test_perplexity_embedding_transformation.pyrename to tests/unit/llms/perplexity/embedding/test_perplexity_embedding_transformation.pydiff --git a/tests/test_litellm/llms/perplexity/responses/test_perplexity_responses_transformation.py b/tests/unit/llms/perplexity/responses/test_perplexity_responses_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/perplexity/responses/test_perplexity_responses_transformation.pyrename to tests/unit/llms/perplexity/responses/test_perplexity_responses_transformation.pydiff --git a/tests/test_litellm/llms/publicai/test_publicai_chat_transformation.py b/tests/unit/llms/publicai/test_publicai_chat_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/publicai/test_publicai_chat_transformation.pyrename to tests/unit/llms/publicai/test_publicai_chat_transformation.pydiff --git a/tests/test_litellm/llms/ragflow/chat/test_ragflow_chat_transformation.py b/tests/unit/llms/ragflow/chat/test_ragflow_chat_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/ragflow/chat/test_ragflow_chat_transformation.pyrename to tests/unit/llms/ragflow/chat/test_ragflow_chat_transformation.pydiff --git a/tests/test_litellm/llms/recraft/image_edit/test_recraft_image_edit_transformation.py b/tests/unit/llms/recraft/image_edit/test_recraft_image_edit_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/recraft/image_edit/test_recraft_image_edit_transformation.pyrename to tests/unit/llms/recraft/image_edit/test_recraft_image_edit_transformation.pydiff --git a/tests/test_litellm/llms/recraft/image_generation/test_recraft_image_gen_transformation.py b/tests/unit/llms/recraft/image_generation/test_recraft_image_gen_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/recraft/image_generation/test_recraft_image_gen_transformation.pyrename to tests/unit/llms/recraft/image_generation/test_recraft_image_gen_transformation.pydiff --git a/tests/test_litellm/llms/runwayml/test_text_to_speech_transformation.py b/tests/unit/llms/runwayml/test_text_to_speech_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/runwayml/test_text_to_speech_transformation.pyrename to tests/unit/llms/runwayml/test_text_to_speech_transformation.pydiff --git a/tests/test_litellm/llms/runwayml/videos/test_runway_video_transformation.py b/tests/unit/llms/runwayml/videos/test_runway_video_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/runwayml/videos/test_runway_video_transformation.pyrename to tests/unit/llms/runwayml/videos/test_runway_video_transformation.pydiff --git a/tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py b/tests/unit/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.pysimilarity index 99%rename from tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.pyrename to tests/unit/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.pyindex 781e92ea7d9..c39887d86ce 100644--- a/tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py+++ b/tests/unit/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py@@ -55,10 +55,6 @@ def _search_kwargs(**overrides):class TestS3VectorsVectorStoreConfig:- def test_init(self):- config = S3VectorsVectorStoreConfig()- assert config is not None-def test_get_supported_openai_params(self):config = S3VectorsVectorStoreConfig()params = config.get_supported_openai_params("test-model")diff --git a/tests/test_litellm/llms/sap/test_sap_fetch_creds.py b/tests/unit/llms/sap/test_sap_fetch_creds.pysimilarity index 100%rename from tests/test_litellm/llms/sap/test_sap_fetch_creds.pyrename to tests/unit/llms/sap/test_sap_fetch_creds.pydiff --git a/tests/test_litellm/llms/scaleway/test_scaleway_audio_transcription_transformation.py b/tests/unit/llms/scaleway/test_scaleway_audio_transcription_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/scaleway/test_scaleway_audio_transcription_transformation.pyrename to tests/unit/llms/scaleway/test_scaleway_audio_transcription_transformation.pydiff --git a/tests/test_litellm/llms/snowflake/test_snowflake_native_endpoints.py b/tests/unit/llms/snowflake/test_snowflake_native_endpoints.pysimilarity index 100%rename from tests/test_litellm/llms/snowflake/test_snowflake_native_endpoints.pyrename to tests/unit/llms/snowflake/test_snowflake_native_endpoints.pydiff --git a/tests/test_litellm/llms/soniox/test_soniox_provider_registration.py b/tests/unit/llms/soniox/test_soniox_provider_registration.pysimilarity index 100%rename from tests/test_litellm/llms/soniox/test_soniox_provider_registration.pyrename to tests/unit/llms/soniox/test_soniox_provider_registration.pydiff --git a/tests/test_litellm/llms/stability/image_generation/test_stability_image_generation.py b/tests/unit/llms/stability/image_generation/test_stability_image_generation.pysimilarity index 93%rename from tests/test_litellm/llms/stability/image_generation/test_stability_image_generation.pyrename to tests/unit/llms/stability/image_generation/test_stability_image_generation.pyindex c5b3c8fbdc5..c5a78603f9c 100644--- a/tests/test_litellm/llms/stability/image_generation/test_stability_image_generation.py+++ b/tests/unit/llms/stability/image_generation/test_stability_image_generation.py@@ -10,10 +10,7 @@ from unittest.mock import MagicMockimport httpximport pytest-from litellm.llms.stability.image_generation import (- StabilityImageGenerationConfig,- get_stability_image_generation_config,-)+from litellm.llms.stability.image_generation import StabilityImageGenerationConfigfrom litellm.types.llms.stability import (OPENAI_SIZE_TO_STABILITY_ASPECT_RATIO,STABILITY_GENERATION_MODELS,@@ -266,20 +263,6 @@ class TestStabilityImageGenerationConfig:assert "filtered" in str(exc_info.value).lower()-class TestFactoryFunction:- """Test the factory function"""-- def test_get_stability_image_generation_config(self):- """Test that factory returns correct config type"""- config = get_stability_image_generation_config("stability/sd3")- assert isinstance(config, StabilityImageGenerationConfig)-- def test_factory_returns_config_for_any_model(self):- """Test that factory works for any model name"""- config = get_stability_image_generation_config("stability/custom-model")- assert isinstance(config, StabilityImageGenerationConfig)--class TestOpenAISizeMapping:"""Test the size to aspect ratio mapping"""diff --git a/tests/test_litellm/llms/tencent/chat/test_tencent_chat_transformation.py b/tests/unit/llms/tencent/chat/test_tencent_chat_transformation.pysimilarity index 100%rename from tests/test_litellm/llms/tencent/chat/test_tencent_chat_transformation.pyrename to tests/unit/llms/tencent/chat/test_tencent_chat_transformation.py