mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(tests): Mock async_container_create_handler for async router test
The test was mocking container_create_handler (sync), but router.acreate_container uses _is_async=True which calls async_container_create_handler. This caused the test to hit the real OpenAI API. Fixed by using AsyncMock on async_container_create_handler.
This commit is contained in:
parent
5efbed3939
commit
375e879e7c
1 changed files with 9 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
|
@ -335,7 +335,14 @@ class TestContainerAPI:
|
|||
name="Test Container"
|
||||
)
|
||||
|
||||
with patch.object(base_llm_http_handler, 'container_create_handler', return_value=mock_response):
|
||||
# Mock async_container_create_handler since router.acreate_container
|
||||
# uses _is_async=True which calls the async handler
|
||||
with patch.object(
|
||||
base_llm_http_handler,
|
||||
'async_container_create_handler',
|
||||
new_callable=AsyncMock,
|
||||
return_value=mock_response
|
||||
):
|
||||
result = await router.acreate_container(
|
||||
name="Test Container",
|
||||
custom_llm_provider="openai"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue