mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
test(router): add coverage for _pre_call_checks_async
This commit is contained in:
parent
ee770c8248
commit
b6b922ad73
1 changed files with 31 additions and 0 deletions
|
|
@ -3329,6 +3329,37 @@ def test_pre_call_checks_no_messages_or_input_does_not_crash(monkeypatch):
|
|||
assert counted == [] # token counting skipped entirely, so no misleading error is logged
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pre_call_checks_async_filters_like_sync():
|
||||
router = litellm.Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "test",
|
||||
"litellm_params": {"model": "gpt-5-mini", "api_key": "sk-test"},
|
||||
"model_info": {"id": "small", "max_input_tokens": 50},
|
||||
},
|
||||
{
|
||||
"model_name": "test",
|
||||
"litellm_params": {"model": "gpt-5.5", "api_key": "sk-test"},
|
||||
"model_info": {"id": "large", "max_input_tokens": 10000},
|
||||
},
|
||||
],
|
||||
enable_pre_call_checks=True,
|
||||
)
|
||||
|
||||
deployments = router.get_model_list(model_name="test")
|
||||
assert deployments is not None
|
||||
|
||||
filtered = await router._pre_call_checks_async(
|
||||
model="test",
|
||||
healthy_deployments=deployments,
|
||||
messages=[{"role": "user", "content": " ".join(["word"] * 100)}],
|
||||
)
|
||||
|
||||
assert len(filtered) == 1
|
||||
assert filtered[0]["model_info"]["id"] == "large"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_aresponses_enforces_context_window_pre_call_check():
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue