mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(test): use patch.object for image_edit and vector_store tests
- test_image_edit_merges_headers_and_extra_headers: import base_llm_http_handler and use patch.object instead of string path patching - test_search_uses_registry_credentials: import module and patch via module.base_llm_http_handler to ensure we patch the right instance
This commit is contained in:
parent
0a313efa9a
commit
75af7eb752
2 changed files with 8 additions and 9 deletions
|
|
@ -1335,6 +1335,8 @@ def test_anthropic_text_disable_url_suffix_env_var():
|
|||
|
||||
|
||||
def test_image_edit_merges_headers_and_extra_headers():
|
||||
from litellm.images.main import base_llm_http_handler
|
||||
|
||||
combined_headers = {
|
||||
"x-test-header-one": "value-1",
|
||||
"x-test-header-two": "value-2",
|
||||
|
|
@ -1351,8 +1353,9 @@ def test_image_edit_merges_headers_and_extra_headers():
|
|||
"litellm.images.main.ProviderConfigManager.get_provider_image_edit_config",
|
||||
return_value=mock_image_edit_config,
|
||||
) as mock_config,
|
||||
patch(
|
||||
"litellm.images.main.base_llm_http_handler.image_edit_handler",
|
||||
patch.object(
|
||||
base_llm_http_handler,
|
||||
"image_edit_handler",
|
||||
return_value="ok",
|
||||
) as mock_handler,
|
||||
):
|
||||
|
|
|
|||
|
|
@ -133,14 +133,10 @@ def test_add_vector_store_to_registry():
|
|||
|
||||
|
||||
|
||||
@respx.mock
|
||||
def test_search_uses_registry_credentials():
|
||||
"""search() should pull credentials from vector_store_registry when available"""
|
||||
# Import the actual instance to patch it correctly
|
||||
from litellm.vector_stores.main import base_llm_http_handler
|
||||
|
||||
# Block all HTTP requests at the network level to prevent real API calls
|
||||
respx.route().mock(return_value=httpx.Response(200, json={"object": "list", "data": []}))
|
||||
# Import the module to get the actual handler instance
|
||||
import litellm.vector_stores.main as vector_stores_main
|
||||
|
||||
vector_store = LiteLLM_ManagedVectorStore(
|
||||
vector_store_id="vs1",
|
||||
|
|
@ -172,7 +168,7 @@ def test_search_uses_registry_credentials():
|
|||
"litellm.vector_stores.main.ProviderConfigManager.get_provider_vector_stores_config",
|
||||
return_value=MagicMock(),
|
||||
), patch.object(
|
||||
base_llm_http_handler,
|
||||
vector_stores_main.base_llm_http_handler,
|
||||
"vector_store_search_handler",
|
||||
return_value=mock_search_response,
|
||||
) as mock_handler:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue