From 1b88cfbe604545f1fed482c6c9945296c73501ee Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 22 Nov 2025 10:43:25 -0800 Subject: [PATCH] test_router_get_deployment_credentials_with_provider --- tests/local_testing/test_router_utils.py | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/local_testing/test_router_utils.py b/tests/local_testing/test_router_utils.py index 09ed29b7ba9..0e3835a7f9d 100644 --- a/tests/local_testing/test_router_utils.py +++ b/tests/local_testing/test_router_utils.py @@ -458,6 +458,50 @@ def test_router_get_deployment_credentials(): assert credentials["api_key"] == "123" +def test_router_get_deployment_credentials_with_provider(): + """ + Test that get_deployment_credentials_with_provider returns credentials with provider info. + """ + router = Router( + model_list=[ + { + "model_name": "gpt-4o", + "litellm_params": { + "model": "gpt-4o", + "api_key": "sk-test-123", + "api_base": "https://api.openai.com/v1", + }, + "model_info": {"id": "openai-deployment-1"}, + }, + { + "model_name": "claude-3", + "litellm_params": { + "model": "anthropic/claude-3-sonnet", + "api_key": "sk-ant-123", + }, + "model_info": {"id": "anthropic-deployment-1"}, + }, + ] + ) + + # Test getting credentials by model_id + credentials = router.get_deployment_credentials_with_provider(model_id="openai-deployment-1") + assert credentials is not None + assert credentials["api_key"] == "sk-test-123" + assert credentials["custom_llm_provider"] == "openai" + assert credentials["api_base"] == "https://api.openai.com/v1" + + # Test getting credentials by model_group_name (model_name) + credentials2 = router.get_deployment_credentials_with_provider(model_id="claude-3") + assert credentials2 is not None + assert credentials2["api_key"] == "sk-ant-123" + assert credentials2["custom_llm_provider"] == "anthropic" + + # Test with non-existent model + credentials3 = router.get_deployment_credentials_with_provider(model_id="non-existent") + assert credentials3 is None + + def test_router_get_deployment_model_info(): router = Router( model_list=[