mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
test(httpx): exercise configured request path
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
534123a49c
commit
1aab2710b5
1 changed files with 37 additions and 0 deletions
|
|
@ -663,6 +663,25 @@ async def test_async_http_handler_http2_transport():
|
|||
monkeypatch.undo()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_http_handler_http2_request():
|
||||
requests: list[httpx.Request] = []
|
||||
|
||||
async def mock_handler(request: httpx.Request) -> httpx.Response:
|
||||
requests.append(request)
|
||||
return httpx.Response(200, request=request, json={"ok": True})
|
||||
|
||||
handler = AsyncHTTPHandler(http2=True)
|
||||
await handler.client.aclose()
|
||||
handler.client = httpx.AsyncClient(transport=httpx.MockTransport(mock_handler))
|
||||
try:
|
||||
response = await handler.get("https://example.com/search")
|
||||
assert response.json() == {"ok": True}
|
||||
assert requests[0].url == "https://example.com/search"
|
||||
finally:
|
||||
await handler.close()
|
||||
|
||||
|
||||
def test_http_handler_http2_transport():
|
||||
http2_handler = HTTPHandler(http2=True)
|
||||
default_handler = HTTPHandler()
|
||||
|
|
@ -674,6 +693,24 @@ def test_http_handler_http2_transport():
|
|||
default_handler.close()
|
||||
|
||||
|
||||
def test_http_handler_http2_request():
|
||||
requests: list[httpx.Request] = []
|
||||
|
||||
def mock_handler(request: httpx.Request) -> httpx.Response:
|
||||
requests.append(request)
|
||||
return httpx.Response(200, request=request, json={"ok": True})
|
||||
|
||||
handler = HTTPHandler(http2=True)
|
||||
handler.client.close()
|
||||
handler.client = httpx.Client(transport=httpx.MockTransport(mock_handler))
|
||||
try:
|
||||
response = handler.get("https://example.com/search")
|
||||
assert response.json() == {"ok": True}
|
||||
assert requests[0].url == "https://example.com/search"
|
||||
finally:
|
||||
handler.close()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_async_httpx_client_http2_cache_key():
|
||||
from litellm.caching.llm_caching_handler import LLMClientCache
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue