mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix: patch HTTPHandler class-level in VLLM embedding test
The test_encoding_format_not_sent_in_actual_request test was patching client.post on an instance, but the handler uses the class method. Patch HTTPHandler.post at class level, add caching=False to prevent cache hits, and remove broad try/except that hid errors. Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
parent
fb238777c1
commit
660f760f93
1 changed files with 12 additions and 12 deletions
|
|
@ -235,14 +235,16 @@ class TestHostedVLLMEmbeddingTransformation:
|
|||
def test_encoding_format_not_sent_in_actual_request(self):
|
||||
"""
|
||||
E2E test that encoding_format is not sent when not provided.
|
||||
|
||||
|
||||
This test mocks the HTTP client to verify the actual request payload.
|
||||
Patches HTTPHandler.post at the class level so the mock is used when
|
||||
base_llm_http_handler calls sync_httpx_client.post() with the passed client.
|
||||
"""
|
||||
from litellm.llms.custom_httpx.http_handler import HTTPHandler
|
||||
|
||||
client = HTTPHandler()
|
||||
|
||||
with patch.object(client, "post") as mock_post:
|
||||
|
||||
with patch.object(HTTPHandler, "post") as mock_post:
|
||||
# Mock response
|
||||
mock_response = Mock()
|
||||
mock_response.status_code = 200
|
||||
|
|
@ -265,15 +267,13 @@ class TestHostedVLLMEmbeddingTransformation:
|
|||
mock_response.text = json.dumps(mock_response.json.return_value)
|
||||
mock_post.return_value = mock_response
|
||||
|
||||
try:
|
||||
litellm.embedding(
|
||||
model=self.model,
|
||||
input=["Hello world"],
|
||||
api_base="https://test-vllm.example.com/v1",
|
||||
client=client,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
litellm.embedding(
|
||||
model=self.model,
|
||||
input=["Hello world"],
|
||||
api_base="https://test-vllm.example.com/v1",
|
||||
client=client,
|
||||
caching=False,
|
||||
)
|
||||
|
||||
# Verify the request was made
|
||||
mock_post.assert_called_once()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue