Bump version to 0.1.2; update logging paths and enhance CLI with version command
This commit is contained in:
@@ -5,6 +5,7 @@ import logging
|
||||
from botocore.exceptions import ClientError
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from nexus_claude_api.errors import NexusClaudeError
|
||||
from nexus_claude_api.config import Settings
|
||||
from nexus_claude_api.nexus_client import _map_client_error
|
||||
from nexus_claude_api.server import create_app
|
||||
@@ -52,6 +53,21 @@ class AccessDeniedNexusClient:
|
||||
)
|
||||
|
||||
|
||||
class StreamErrorNexusClient:
|
||||
def converse_stream(self, request: dict, *, correlation_id: str | None = None):
|
||||
assert correlation_id
|
||||
|
||||
def events():
|
||||
yield {"contentBlockDelta": {"contentBlockIndex": 0, "delta": {"text": "Hi"}}}
|
||||
raise NexusClaudeError(
|
||||
"stream failed",
|
||||
status_code=502,
|
||||
error_type="api_error",
|
||||
)
|
||||
|
||||
return events()
|
||||
|
||||
|
||||
def client(nexus_client: object | None = None) -> TestClient:
|
||||
settings = Settings.from_values(api_key="test", require_api_key=False)
|
||||
return TestClient(
|
||||
@@ -183,6 +199,26 @@ def test_messages_stream() -> None:
|
||||
assert "event: message_stop" in body
|
||||
|
||||
|
||||
def test_messages_stream_returns_sse_error_when_stream_iteration_fails() -> None:
|
||||
with client(StreamErrorNexusClient()).stream(
|
||||
"POST",
|
||||
"/v1/messages",
|
||||
json={
|
||||
"model": "claude-opus-4.6",
|
||||
"messages": [{"role": "user", "content": "Hello"}],
|
||||
"max_tokens": 32,
|
||||
"stream": True,
|
||||
},
|
||||
) as response:
|
||||
body = response.read().decode("utf-8")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "event: content_block_delta" in body
|
||||
assert "event: error" in body
|
||||
assert "stream failed" in body
|
||||
assert "correlation_id" in body
|
||||
|
||||
|
||||
def test_count_tokens() -> None:
|
||||
response = client().post(
|
||||
"/v1/messages/count_tokens",
|
||||
|
||||
Reference in New Issue
Block a user