1515 pytest tests/test_agent.py -v
1616"""
1717
18+ import pytest
19+
1820from agentex .lib .testing import (
1921 test_sync_agent ,
2022 collect_streaming_deltas ,
2426AGENT_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 } \n Got: { 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