mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix(test): use _ageneric_api_call_with_fallbacks directly in e2e test
anthropic_messages does not support mock_response and requires max_tokens; route through _ageneric_api_call_with_fallbacks with _acompletion instead to test the exact code path that was broken
This commit is contained in:
parent
5795f532e5
commit
40d25ca81e
1 changed files with 10 additions and 5 deletions
|
|
@ -813,11 +813,15 @@ async def test_generic_api_path_sets_failed_deployment_id():
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_weighted_failover_works_on_generic_api_path():
|
||||
"""End-to-end: weighted failover via the _ageneric_api_call_with_fallbacks
|
||||
path (used by /v1/messages, image_edit, generate_content, etc.) should
|
||||
"""End-to-end: weighted failover via _ageneric_api_call_with_fallbacks
|
||||
(used by /v1/messages, image_edit, generate_content, etc.) should
|
||||
re-pick a healthy sibling in the same model group before falling back
|
||||
to a cross-group fallback. Uses anthropic_messages to exercise the
|
||||
exact code path reported in the bug."""
|
||||
to a cross-group fallback.
|
||||
|
||||
Exercises the generic path directly with _acompletion (which supports
|
||||
mock_response) to validate that the fix in
|
||||
_ageneric_api_call_with_fallbacks_helper propagates through the full
|
||||
async_function_with_fallbacks retry chain."""
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
|
|
@ -846,8 +850,9 @@ async def test_weighted_failover_works_on_generic_api_path():
|
|||
enable_weighted_failover=True,
|
||||
)
|
||||
|
||||
response = await router.anthropic_messages(
|
||||
response = await router._ageneric_api_call_with_fallbacks(
|
||||
model="test-model",
|
||||
original_function=router._acompletion,
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
)
|
||||
assert response._hidden_params["model_id"] == "B"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue