From d3a2cb2b754f3cc47e173ec482c50fb6044165a8 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 23:23:12 +0000 Subject: [PATCH] test(router): cover xai-oauth alias helpers for router coverage gate --- tests/test_litellm/test_router.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.py index 350203007e1..47d53933df2 100644 --- a/tests/test_litellm/test_router.py +++ b/tests/test_litellm/test_router.py @@ -1111,6 +1111,33 @@ def test_router_leaves_plain_xai_deployment_untouched(): assert not deployment.get("use_xai_oauth") +def test_normalize_xai_oauth_alias_model_helper(): + assert litellm.Router._normalize_xai_oauth_alias_model("xai-oauth/grok-4.5", None) == "xai/grok-4.5" + assert litellm.Router._normalize_xai_oauth_alias_model("grok-4.5", "xai_oauth") == "xai/grok-4.5" + assert litellm.Router._normalize_xai_oauth_alias_model("xai/grok-4.5", "xai-oauth") == "xai/grok-4.5" + assert litellm.Router._normalize_xai_oauth_alias_model("xai/grok-4.5", None) is None + assert litellm.Router._normalize_xai_oauth_alias_model("openai/gpt-4o", None) is None + + +def test_apply_xai_oauth_alias_helper(): + router = litellm.Router( + model_list=[ + {"model_name": "grok-4.5", "litellm_params": {"model": "xai/grok-4.5"}} + ] + ) + + normalized = router._apply_xai_oauth_alias( + {"model": "grok-4.5", "custom_llm_provider": "xai-oauth", "api_base": "https://x"} + ) + assert normalized["model"] == "xai/grok-4.5" + assert normalized["use_xai_oauth"] is True + assert "custom_llm_provider" not in normalized + assert normalized["api_base"] == "https://x" + + untouched = {"model": "openai/gpt-4o"} + assert router._apply_xai_oauth_alias(untouched) is untouched + + @pytest.mark.asyncio async def test_router_ageneric_api_call_with_fallbacks_helper(): """