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
fixes: ci pipeline router coverage failure (#20065)
Harshit Jain481bb4b6ceb4
diff --git a/tests/test_litellm/test_router_silent_experiment.py b/tests/test_litellm/test_router_silent_experiment.pyindex 9b82cde13c6..3afb9444391 100644--- a/tests/test_litellm/test_router_silent_experiment.py+++ b/tests/test_litellm/test_router_silent_experiment.py@@ -1,5 +1,5 @@import asyncio-from unittest.mock import MagicMock, patch+from unittest.mock import AsyncMock, MagicMock, patchimport pytest@@ -7,6 +7,66 @@ import litellmfrom litellm.router import Router+def test_get_silent_experiment_kwargs():+ """+ Test _get_silent_experiment_kwargs returns isolated kwargs with silent experiment metadata.+ Direct call for router code coverage.+ """+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {"model": "gpt-3.5-turbo", "api_key": "fake-key"},+ },+ ]+ router = Router(model_list=model_list)+ kwargs = {"metadata": {"foo": "bar"}, "litellm_call_id": "call-123"}+ result = router._get_silent_experiment_kwargs(**kwargs)+ assert result["metadata"]["is_silent_experiment"] is True+ assert result["metadata"]["foo"] == "bar"+ assert "litellm_call_id" not in result+++def test_silent_experiment_completion_direct():+ """+ Test _silent_experiment_completion directly (for router code coverage).+ Mocks router.completion to avoid real API call.+ """+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {"model": "gpt-3.5-turbo", "api_key": "fake-key"},+ },+ ]+ router = Router(model_list=model_list)+ messages = [{"role": "user", "content": "hi"}]+ with patch.object(router, "completion", return_value=None):+ router._silent_experiment_completion(+ silent_model="gpt-3.5-turbo",+ messages=messages,+ )+++async def test_silent_experiment_acompletion_direct():+ """+ Test _silent_experiment_acompletion directly (for router code coverage).+ Mocks router.acompletion to avoid real API call.+ """+ model_list = [+ {+ "model_name": "gpt-3.5-turbo",+ "litellm_params": {"model": "gpt-3.5-turbo", "api_key": "fake-key"},+ },+ ]+ router = Router(model_list=model_list)+ messages = [{"role": "user", "content": "hi"}]+ with patch.object(router, "acompletion", new_callable=AsyncMock, return_value=None):+ await router._silent_experiment_acompletion(+ silent_model="gpt-3.5-turbo",+ messages=messages,+ )++@pytest.mark.asyncioasync def test_router_silent_experiment_acompletion():"""