Fix:test_aaaaazure_tenant_id_auth

This commit is contained in:
Sameer Kankute
2026-01-20 17:39:08 +05:30
parent f0785d5a51
commit cd96c8cbb0
4 changed files with 16 additions and 6 deletions
+2 -2
View File
@@ -215,7 +215,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
### CHECK IF CLOUDFLARE AI GATEWAY ###
### if so - set the model as part of the base url
if "gateway.ai.cloudflare.com" in api_base:
if api_base is not None and "gateway.ai.cloudflare.com" in api_base:
client = self._init_azure_client_for_cloudflare_ai_gateway(
api_base=api_base,
model=model,
@@ -1338,7 +1338,7 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):
prompt: Optional[str] = None,
) -> dict:
client_session = litellm.client_session or httpx.Client()
if "gateway.ai.cloudflare.com" in api_base:
if api_base is not None and "gateway.ai.cloudflare.com" in api_base:
## build base url - assume api base includes resource name
if not api_base.endswith("/"):
api_base += "/"
+7 -3
View File
@@ -1168,8 +1168,10 @@ def get_async_httpx_client(
return _cached_client
if params is not None:
params["shared_session"] = shared_session
_new_client = AsyncHTTPHandler(**params)
# Filter out params that are only used for cache key, not for AsyncHTTPHandler.__init__
handler_params = {k: v for k, v in params.items() if k != "disable_aiohttp_transport"}
handler_params["shared_session"] = shared_session
_new_client = AsyncHTTPHandler(**handler_params)
else:
_new_client = AsyncHTTPHandler(
timeout=httpx.Timeout(timeout=600.0, connect=5.0),
@@ -1215,7 +1217,9 @@ def _get_httpx_client(params: Optional[dict] = None) -> HTTPHandler:
return _cached_client
if params is not None:
_new_client = HTTPHandler(**params)
# Filter out params that are only used for cache key, not for HTTPHandler.__init__
handler_params = {k: v for k, v in params.items() if k != "disable_aiohttp_transport"}
_new_client = HTTPHandler(**handler_params)
else:
_new_client = HTTPHandler(timeout=httpx.Timeout(timeout=600.0, connect=5.0))
+2 -1
View File
@@ -212,7 +212,8 @@ class BaseOpenAILLM:
try:
# Get SSL config and include in params for proper cache key
ssl_config = get_ssl_configuration()
params = {"ssl_verify": ssl_config} if ssl_config is not None else None
params = {"ssl_verify": ssl_config} if ssl_config is not None else {}
params["disable_aiohttp_transport"] = litellm.disable_aiohttp_transport
# Get a cached AsyncHTTPHandler which manages the httpx.AsyncClient
cached_handler = get_async_httpx_client(
+5
View File
@@ -41,6 +41,11 @@ async def test_aaaaazure_tenant_id_auth(respx_mock: MockRouter):
PROD Test
"""
litellm.disable_aiohttp_transport = True # since this uses respx, we need to set use_aiohttp_transport to False
# Clear the HTTP client cache to ensure respx mocking works
# This is critical because respx only intercepts clients created AFTER mocking is active
if hasattr(litellm, 'in_memory_llm_clients_cache'):
litellm.in_memory_llm_clients_cache.flush_cache()
router = Router(
model_list=[