mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 04:31:02 +02:00
Fixed the tests
This commit is contained in:
parent
5a2f04a8aa
commit
7f9fe96492
1 changed files with 19 additions and 5 deletions
|
|
@ -230,11 +230,14 @@ class TestPromptStreaming:
|
||||||
|
|
||||||
text_completion_client.request = failing_request
|
text_completion_client.request = failing_request
|
||||||
|
|
||||||
|
# Mock response producer to capture error response
|
||||||
|
response_producer = AsyncMock()
|
||||||
|
|
||||||
def context_router(service_name):
|
def context_router(service_name):
|
||||||
if service_name == "text-completion-request":
|
if service_name == "text-completion-request":
|
||||||
return text_completion_client
|
return text_completion_client
|
||||||
elif service_name == "response":
|
elif service_name == "response":
|
||||||
return AsyncMock()
|
return response_producer
|
||||||
else:
|
else:
|
||||||
return AsyncMock()
|
return AsyncMock()
|
||||||
|
|
||||||
|
|
@ -252,11 +255,22 @@ class TestPromptStreaming:
|
||||||
|
|
||||||
consumer = MagicMock()
|
consumer = MagicMock()
|
||||||
|
|
||||||
# Act & Assert
|
# Act - The service catches errors and sends error responses, doesn't raise
|
||||||
with pytest.raises(RuntimeError) as exc_info:
|
await prompt_processor_streaming.on_request(message, consumer, context)
|
||||||
await prompt_processor_streaming.on_request(message, consumer, context)
|
|
||||||
|
|
||||||
assert "Text completion error" in str(exc_info.value)
|
# Assert - Verify error response was sent
|
||||||
|
assert response_producer.send.call_count > 0
|
||||||
|
|
||||||
|
# Check that at least one response contains an error
|
||||||
|
error_sent = False
|
||||||
|
for call in response_producer.send.call_args_list:
|
||||||
|
response = call.args[0]
|
||||||
|
if hasattr(response, 'error') and response.error:
|
||||||
|
error_sent = True
|
||||||
|
assert "Text completion error" in response.error.message
|
||||||
|
break
|
||||||
|
|
||||||
|
assert error_sent, "Expected error response to be sent"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_prompt_streaming_preserves_message_id(self, prompt_processor_streaming,
|
async def test_prompt_streaming_preserves_message_id(self, prompt_processor_streaming,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue