Skip to content

Commit 97811c3

Browse files
committed
Update test_agent.py
1 parent dc6b988 commit 97811c3

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

examples/tutorials/00_sync/000_hello_acp/tests/test_agent.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
pytest tests/test_agent.py -v
1616
"""
1717

18+
import pytest
19+
1820
from agentex.lib.testing import (
1921
test_sync_agent,
2022
collect_streaming_deltas,
@@ -24,11 +26,25 @@
2426
AGENT_NAME = "s000-hello-acp"
2527

2628

27-
def test_send_simple_message():
28-
"""Test sending a simple message and receiving a response."""
29-
with test_sync_agent(agent_name=AGENT_NAME) as test:
29+
@pytest.fixture
30+
def agent_name():
31+
"""Return the agent name for testing."""
32+
return AGENT_NAME
33+
34+
@pytest.fixture
35+
def test_agent(agent_name: str):
36+
"""Fixture to create a test sync agent."""
37+
with test_sync_agent(agent_name=agent_name) as test:
38+
yield test
39+
40+
41+
class TestNonStreamingMessages:
42+
"""Tests for non-streaming message sending."""
43+
44+
def test_send_simple_message(self, test_agent):
45+
"""Test sending a simple message and receiving a response."""
3046
message_content = "Hello, Agent! How are you?"
31-
response = test.send_message(message_content)
47+
response = test_agent.send_message(message_content)
3248

3349
# Validate response
3450
assert_valid_agent_response(response)
@@ -37,14 +53,16 @@ def test_send_simple_message():
3753
expected = f"Hello! I've received your message. Here's a generic response, but in future tutorials we'll see how you can get me to intelligently respond to your message. This is what I heard you say: {message_content}"
3854
assert response.content == expected, f"Expected: {expected}\nGot: {response.content}"
3955

56+
class TestStreamingMessages:
57+
"""Tests for streaming message sending."""
58+
4059

41-
def test_stream_simple_message():
42-
"""Test streaming a simple message and aggregating deltas."""
43-
with test_sync_agent(agent_name=AGENT_NAME) as test:
60+
def test_stream_simple_message(self, test_agent):
61+
"""Test streaming a simple message and aggregating deltas."""
4462
message_content = "Hello, Agent! Can you stream your response?"
4563

4664
# Get streaming response
47-
response_gen = test.send_message_streaming(message_content)
65+
response_gen = test_agent.send_message_streaming(message_content)
4866

4967
# Collect streaming deltas
5068
aggregated_content, chunks = collect_streaming_deltas(response_gen)

0 commit comments

Comments
 (0)