mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-10 05:24:39 +00:00
Merge branch 'main' into prompt-api
This commit is contained in:
commit
14f7b0d843
8 changed files with 92 additions and 13 deletions
|
@ -5,6 +5,8 @@
|
|||
# the root directory of this source tree.
|
||||
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from ..test_cases.test_case import TestCase
|
||||
|
@ -323,8 +325,15 @@ def test_inference_store(compat_client, client_with_models, text_model_id, strea
|
|||
response_id = response.id
|
||||
content = response.choices[0].message.content
|
||||
|
||||
responses = client.chat.completions.list(limit=1000)
|
||||
assert response_id in [r.id for r in responses.data]
|
||||
tries = 0
|
||||
while tries < 10:
|
||||
responses = client.chat.completions.list(limit=1000)
|
||||
if response_id in [r.id for r in responses.data]:
|
||||
break
|
||||
else:
|
||||
tries += 1
|
||||
time.sleep(0.1)
|
||||
assert tries < 10, f"Response {response_id} not found after 1 second"
|
||||
|
||||
retrieved_response = client.chat.completions.retrieve(response_id)
|
||||
assert retrieved_response.id == response_id
|
||||
|
@ -388,6 +397,18 @@ def test_inference_store_tool_calls(compat_client, client_with_models, text_mode
|
|||
response_id = response.id
|
||||
content = response.choices[0].message.content
|
||||
|
||||
# wait for the response to be stored
|
||||
tries = 0
|
||||
while tries < 10:
|
||||
responses = client.chat.completions.list(limit=1000)
|
||||
if response_id in [r.id for r in responses.data]:
|
||||
break
|
||||
else:
|
||||
tries += 1
|
||||
time.sleep(0.1)
|
||||
|
||||
assert tries < 10, f"Response {response_id} not found after 1 second"
|
||||
|
||||
responses = client.chat.completions.list(limit=1000)
|
||||
assert response_id in [r.id for r in responses.data]
|
||||
|
||||
|
|
|
@ -113,6 +113,15 @@ class TestTranslateException:
|
|||
assert result.status_code == 504
|
||||
assert result.detail == "Operation timed out: "
|
||||
|
||||
def test_translate_connection_error(self):
|
||||
"""Test that ConnectionError is translated to 502 HTTP status."""
|
||||
exc = ConnectionError("Failed to connect to MCP server at http://localhost:9999/sse: Connection refused")
|
||||
result = translate_exception(exc)
|
||||
|
||||
assert isinstance(result, HTTPException)
|
||||
assert result.status_code == 502
|
||||
assert result.detail == "Failed to connect to MCP server at http://localhost:9999/sse: Connection refused"
|
||||
|
||||
def test_translate_not_implemented_error(self):
|
||||
"""Test that NotImplementedError is translated to 501 HTTP status."""
|
||||
exc = NotImplementedError("Not implemented")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue