mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(test - watsonx) use MagicMock to mock httpx.AsyncClient endpoint for aembedding test
This commit is contained in:
parent
8caec84cc2
commit
e2827ee28b
1 changed files with 16 additions and 19 deletions
|
@ -518,28 +518,25 @@ def test_watsonx_embeddings():
|
|||
async def test_watsonx_aembeddings():
|
||||
|
||||
def mock_async_client(*args, **kwargs):
|
||||
|
||||
mocked_client = MagicMock()
|
||||
|
||||
class MockedAsyncClient:
|
||||
def __init__(*args, **kwargs):
|
||||
pass
|
||||
|
||||
async def send(self, request, *args, stream: bool = False, **kwags):
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.headers = {"Content-Type": "application/json"}
|
||||
mock_response.json.return_value = {
|
||||
"model_id": "ibm/slate-30m-english-rtrvr",
|
||||
"created_at": "2024-01-01T00:00:00.00Z",
|
||||
"results": [ {"embedding": [0.0]*254} ],
|
||||
"input_token_count": 8
|
||||
}
|
||||
mock_response.is_error = False
|
||||
return mock_response
|
||||
async def mock_send(request, *args, stream: bool = False, **kwags):
|
||||
mock_response = MagicMock()
|
||||
mock_response.status_code = 200
|
||||
mock_response.headers = {"Content-Type": "application/json"}
|
||||
mock_response.json.return_value = {
|
||||
"model_id": "ibm/slate-30m-english-rtrvr",
|
||||
"created_at": "2024-01-01T00:00:00.00Z",
|
||||
"results": [ {"embedding": [0.0]*254} ],
|
||||
"input_token_count": 8
|
||||
}
|
||||
mock_response.is_error = False
|
||||
return mock_response
|
||||
|
||||
def build_request(*args, **kwargs):
|
||||
pass
|
||||
mocked_client.send = mock_send
|
||||
|
||||
return MockedAsyncClient(*args, **kwargs)
|
||||
return mocked_client
|
||||
|
||||
try:
|
||||
litellm.set_verbose = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue