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 wrapper
This commit is contained in:
parent
e1f39ab22a
commit
ee770c8248
1 changed files with 32 additions and 0 deletions
|
|
@ -145,5 +145,37 @@ class TestPreCallChecksOptimization:
|
|||
), "Second deployment ID changed!"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_wrapper_filters_like_sync():
|
||||
router = 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},
|
||||
},
|
||||
],
|
||||
set_verbose=False,
|
||||
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"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v"])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue