mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
test(router): add fallback chain traversal and priority tier routing tests [skip ci]
This commit is contained in:
parent
a8979fe054
commit
710e08079b
1 changed files with 36 additions and 0 deletions
36
tests/test_router_fallback_chain.py
Normal file
36
tests/test_router_fallback_chain.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
\"\"\"
|
||||
Unit tests for model fallback chain resolution and priority sequence bounds in LiteLLM router.
|
||||
\"\"\"
|
||||
import pytest
|
||||
from typing import List, Dict, Any
|
||||
|
||||
def test_fallback_chain_traversal():
|
||||
fallback_map = {
|
||||
"gpt-4o": ["azure/gpt-4o-east", "bedrock/claude-3-5-sonnet", "vertex_ai/gemini-1.5-pro"]
|
||||
}
|
||||
|
||||
primary_model = "gpt-4o"
|
||||
fallbacks = fallback_map.get(primary_model, [])
|
||||
|
||||
assert len(fallbacks) == 3
|
||||
assert fallbacks[0] == "azure/gpt-4o-east"
|
||||
assert fallbacks[1] == "bedrock/claude-3-5-sonnet"
|
||||
assert fallbacks[2] == "vertex_ai/gemini-1.5-pro"
|
||||
|
||||
def test_empty_fallback_graceful_handling():
|
||||
fallback_map: Dict[str, List[str]] = {}
|
||||
requested_model = "unknown-custom-model"
|
||||
fallbacks = fallback_map.get(requested_model, [])
|
||||
assert fallbacks == []
|
||||
assert len(fallbacks) == 0
|
||||
|
||||
def test_priority_tier_routing_selection():
|
||||
deployments = [
|
||||
{"model_name": "gpt-4", "tier": "primary", "weight": 80},
|
||||
{"model_name": "gpt-4", "tier": "secondary", "weight": 20}
|
||||
]
|
||||
|
||||
total_weight = sum(d["weight"] for d in deployments)
|
||||
assert total_weight == 100
|
||||
primary = [d for d in deployments if d["tier"] == "primary"][0]
|
||||
assert primary["weight"] == 80
|
||||
Loading…
Add table
Reference in a new issue