Skip to content

Commit 9d0b787

Browse files
committed
feat: Add test for send_message that returns a Message
1 parent 85bcf6f commit 9d0b787

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/client/test_grpc_client.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
TaskStatus,
1919
TextPart,
2020
)
21-
from a2a.utils import proto_utils
21+
from a2a.utils import get_text_parts, proto_utils
2222

2323

2424
# Fixtures
@@ -112,6 +112,26 @@ async def test_send_message_task_response(
112112
assert response.id == sample_task.id
113113

114114

115+
@pytest.mark.asyncio
116+
async def test_send_message_message_response(
117+
grpc_transport: GrpcTransport,
118+
mock_grpc_stub: AsyncMock,
119+
sample_message_send_params: MessageSendParams,
120+
sample_message: Message,
121+
):
122+
"""Test send_message that returns a Message."""
123+
mock_grpc_stub.SendMessage.return_value = a2a_pb2.SendMessageResponse(
124+
msg=proto_utils.ToProto.message(sample_message)
125+
)
126+
127+
response = await grpc_transport.send_message(sample_message_send_params)
128+
129+
mock_grpc_stub.SendMessage.assert_awaited_once()
130+
assert isinstance(response, Message)
131+
assert response.message_id == sample_message.message_id
132+
assert get_text_parts(response.parts) == get_text_parts(sample_message.parts)
133+
134+
115135
@pytest.mark.asyncio
116136
async def test_get_task(
117137
grpc_transport: GrpcTransport, mock_grpc_stub: AsyncMock, sample_task: Task

0 commit comments

Comments
 (0)