From a7d4f7f13121c684028b454ed43b7c953e8ef20b Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 18 Jun 2026 13:37:20 +0000 Subject: [PATCH] test(router): cover _underlying_model_for_group alias resolution The router code-coverage gate requires every router.py function to be exercised by a test file whose name contains "router". Add a focused test that builds a Router with an aliased deployment and asserts the group name resolves to the deployment's registry model, with None for unknown groups. --- tests/test_litellm/test_router.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.py index 830edf6412d..a839d81f025 100644 --- a/tests/test_litellm/test_router.py +++ b/tests/test_litellm/test_router.py @@ -4756,3 +4756,27 @@ def test_is_deployment_blocked_static_helper_reflects_blocked_flag(): ) is True ) + + +def test_underlying_model_for_group_resolves_alias(): + """The mid-stream prefill check resolves a custom router group name to the + deployment's registry model, so an alias like "production-claude" surfaces + "anthropic/claude-sonnet-4-6" (which the registry keys on) instead of the + unregistered alias. Unknown groups return None.""" + router = litellm.Router( + model_list=[ + { + "model_name": "production-claude", + "litellm_params": { + "model": "anthropic/claude-sonnet-4-6", + "api_key": "sk-fake", + }, + } + ], + ) + + assert ( + router._underlying_model_for_group("production-claude") + == "anthropic/claude-sonnet-4-6" + ) + assert router._underlying_model_for_group("nonexistent-group") is None