From 0947178aff99047bda3f1054e716e59188d14847 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sun, 8 Nov 2026 11:36:20 -0800 Subject: [PATCH] test: cover a gateway alias whose Claude base_model is only in model_info --- .../test_anthropic_cache_control_hook.py | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/tests/unit/integrations/test_anthropic_cache_control_hook.py b/tests/unit/integrations/test_anthropic_cache_control_hook.py index d08a1bafbed..15c53a6c945 100644 --- a/tests/unit/integrations/test_anthropic_cache_control_hook.py +++ b/tests/unit/integrations/test_anthropic_cache_control_hook.py @@ -6606,9 +6606,22 @@ async def test_system_injection_point_leaves_a_developer_prompt_for_a_routed_gem assert "cache_control" not in route.calls.last.request.content.decode() -def test_system_injection_point_marks_a_developer_prompt_for_a_gateway_alias_with_a_claude_base_model( +@pytest.mark.parametrize( + "deployment_fields", + [ + pytest.param({"base_model": "anthropic/claude-haiku-5-5"}, id="base_model"), + pytest.param({"model_info": {"base_model": "anthropic/claude-haiku-5-5"}}, id="model_info_base_model"), + ], +) +@pytest.mark.parametrize("asynchronous", [False, True], ids=["completion", "acompletion"]) +@pytest.mark.asyncio +async def test_system_injection_point_marks_a_developer_prompt_for_a_gateway_alias_with_a_claude_base_model( + deployment_fields: dict[str, object], + asynchronous: bool, respx_mock: respx.MockRouter, + monkeypatch: pytest.MonkeyPatch, ) -> None: + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) route: Final = respx_mock.post(_GATEWAY_URL).mock( return_value=Response( 200, @@ -6625,17 +6638,21 @@ def test_system_injection_point_marks_a_developer_prompt_for_a_gateway_alias_wit ) ) - litellm.completion( - model="litellm_proxy/team-assistant", - messages=[ + request: Final = { + "model": "litellm_proxy/team-assistant", + "messages": [ {"role": "developer", "content": _DEVELOPER_PREFIX}, {"role": "user", "content": "Which rule covers backups?"}, ], - cache_control_injection_points=[{"location": "message", "role": "system"}], - api_key="offline-key", - api_base=_GATEWAY_URL.removesuffix("/chat/completions"), - base_model="anthropic/claude-haiku-5-5", - ) + "cache_control_injection_points": [{"location": "message", "role": "system"}], + "api_key": "offline-key", + "api_base": _GATEWAY_URL.removesuffix("/chat/completions"), + **deployment_fields, + } + if asynchronous: + await litellm.acompletion(**request) + else: + litellm.completion(**request) assert json.loads(route.calls.last.request.content)["messages"][0] == { "role": "system",