test(router): cover passthrough stream_timeout without patching proxy globals

This commit is contained in:
clonylu 2026-09-15 16:11:55 +08:00
parent 163c0f3aee
commit efb2bcd87f
2 changed files with 38 additions and 32 deletions

View file

@ -1167,14 +1167,14 @@ def test_resolve_llm_passthrough_timeout_stream_timeout_precedence():
)
== 90.0
)
with patch("litellm.proxy.proxy_server.general_settings", {}):
assert (
resolve_llm_passthrough_timeout(
litellm_params={"stream_timeout": 1800},
router_stream_timeout=1800,
)
== DEFAULT_PASS_THROUGH_REQUEST_TIMEOUT_SECONDS
assert (
resolve_llm_passthrough_timeout(
litellm_params={"stream_timeout": 1800},
router_timeout=120,
router_stream_timeout=1800,
)
== 120.0
)
@pytest.mark.asyncio

View file

@ -5494,6 +5494,7 @@ def test_update_kwargs_with_deployment_passthrough_honors_stream_timeout():
"litellm_params": {
"model": "anthropic/claude-sonnet-4-5",
"api_key": "fake-key",
"timeout": 60,
"stream_timeout": 1800,
},
},
@ -5505,37 +5506,42 @@ def test_update_kwargs_with_deployment_passthrough_honors_stream_timeout():
},
},
],
timeout=120,
stream_timeout=900,
)
per_deployment, router_default = router.model_list
with patch(
"litellm.proxy.proxy_server.general_settings",
{"pass_through_request_timeout": 6},
):
kwargs: dict = {"stream": True}
router._update_kwargs_with_deployment(
deployment=per_deployment,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 1800.0
kwargs: dict = {"stream": True}
router._update_kwargs_with_deployment(
deployment=per_deployment,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 1800.0
kwargs = {"stream": True}
router._update_kwargs_with_deployment(
deployment=router_default,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 900.0
kwargs = {"stream": True}
router._update_kwargs_with_deployment(
deployment=router_default,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 900.0
kwargs = {"stream": False}
router._update_kwargs_with_deployment(
deployment=per_deployment,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 6.0
kwargs = {"stream": False}
router._update_kwargs_with_deployment(
deployment=per_deployment,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 60.0
kwargs = {"stream": False}
router._update_kwargs_with_deployment(
deployment=router_default,
kwargs=kwargs,
function_name="_ageneric_api_call_with_fallbacks",
)
assert kwargs["timeout"] == 120.0
@pytest.mark.asyncio