From 57085d958b53a69941fd2ce3ff66567a7c31d6c2 Mon Sep 17 00:00:00 2001 From: Denis Khachyan Date: Thu, 28 May 2026 11:49:21 +0300 Subject: [PATCH] test: add ProviderConfigManager coverage for hosted_vllm branch Exercises the real (unmocked) get_provider_anthropic_messages_config with HOSTED_VLLM provider to cover the 5 lines that codecov/patch flagged. Co-Authored-By: Claude Opus 4.7 --- .../hosted_vllm/test_anthropic_passthrough.py | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tests/litellm/llms/hosted_vllm/test_anthropic_passthrough.py b/tests/litellm/llms/hosted_vllm/test_anthropic_passthrough.py index fc26e4102cb..1f7436d12c0 100644 --- a/tests/litellm/llms/hosted_vllm/test_anthropic_passthrough.py +++ b/tests/litellm/llms/hosted_vllm/test_anthropic_passthrough.py @@ -305,3 +305,72 @@ class TestHandlerRouting: ) mock_translate.assert_called_once() + + +# --------------------------------------------------------------------------- +# ProviderConfigManager integration — real (unmocked) path +# --------------------------------------------------------------------------- + + +class TestProviderConfigManager: + """Exercises the real ProviderConfigManager.get_provider_anthropic_messages_config + to cover the hosted_vllm branch that CI codecov flags as uncovered.""" + + def test_hosted_vllm_with_flag_returns_config(self): + from litellm.utils import ProviderConfigManager + + params = GenericLiteLLMParams(disable_anthropic_translation=True) + with patch.dict(os.environ, {}, clear=False): + os.environ.pop("DISABLE_HOSTED_VLLM_ANTHROPIC_TRANSLATION", None) + config = ProviderConfigManager.get_provider_anthropic_messages_config( + model="qwen36-27b", + provider=litellm.LlmProviders.HOSTED_VLLM, + litellm_params=params, + ) + assert isinstance(config, HostedVLLMAnthropicMessagesConfig) + + def test_hosted_vllm_without_flag_returns_none(self): + from litellm.utils import ProviderConfigManager + + params = GenericLiteLLMParams() + with patch.dict(os.environ, {}, clear=False): + os.environ.pop("DISABLE_HOSTED_VLLM_ANTHROPIC_TRANSLATION", None) + config = ProviderConfigManager.get_provider_anthropic_messages_config( + model="qwen36-27b", + provider=litellm.LlmProviders.HOSTED_VLLM, + litellm_params=params, + ) + assert config is None + + def test_hosted_vllm_no_litellm_params_returns_none(self): + from litellm.utils import ProviderConfigManager + + config = ProviderConfigManager.get_provider_anthropic_messages_config( + model="qwen36-27b", + provider=litellm.LlmProviders.HOSTED_VLLM, + litellm_params=None, + ) + assert config is None + + def test_hosted_vllm_env_var_returns_config(self): + from litellm.utils import ProviderConfigManager + + params = GenericLiteLLMParams() + with patch.dict(os.environ, {"DISABLE_HOSTED_VLLM_ANTHROPIC_TRANSLATION": "true"}): + config = ProviderConfigManager.get_provider_anthropic_messages_config( + model="qwen36-27b", + provider=litellm.LlmProviders.HOSTED_VLLM, + litellm_params=params, + ) + assert isinstance(config, HostedVLLMAnthropicMessagesConfig) + + def test_non_hosted_vllm_delegates_to_cached(self): + from litellm.utils import ProviderConfigManager + + config = ProviderConfigManager.get_provider_anthropic_messages_config( + model="claude-3", + provider=litellm.LlmProviders.ANTHROPIC, + litellm_params=None, + ) + assert config is not None + assert not isinstance(config, HostedVLLMAnthropicMessagesConfig)