Skip to content

Commit f30eff8

Browse files
committed
fix
1 parent 65d8e84 commit f30eff8

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

src/a2a/server/request_handlers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __init__(self, *args, **kwargs):
3838
__all__ = [
3939
'DefaultRequestHandler',
4040
'GrpcHandler',
41-
'JSONRPCHandler',
4241
'RequestHandler',
4342
'build_error_response',
4443
'prepare_response_object',

tests/server/routes/test_rest_dispatcher.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ async def test_build_call_context(self, rest_dispatcher_instance):
139139

140140
@pytest.mark.asyncio
141141
class TestRestDispatcherEndpoints:
142+
async def test_on_message_send_throws_error_for_unsupported_version(
143+
self, rest_dispatcher_instance, mock_handler
144+
):
145+
# 0.3 is currently not supported for direct message sending on RestDispatcher
146+
req = make_mock_request(method='POST', headers={'a2a-version': '0.3.0'})
147+
response = await rest_dispatcher_instance.on_message_send(req)
148+
149+
# VersionNotSupportedError maps to 400 Bad Request
150+
assert response.status_code == 400
151+
142152
async def test_on_message_send_returns_message(
143153
self, rest_dispatcher_instance, mock_handler
144154
):
@@ -286,3 +296,36 @@ async def test_on_subscribe_to_task_unsupported(
286296

287297
response = await dispatcher.on_subscribe_to_task(req)
288298
assert response.status_code == 400
299+
300+
async def test_on_message_send_stream_success(
301+
self, rest_dispatcher_instance
302+
):
303+
req = make_mock_request(method='POST')
304+
response = await rest_dispatcher_instance.on_message_send_stream(req)
305+
306+
assert response.status_code == 200
307+
308+
chunks = []
309+
async for chunk in response.body_iterator:
310+
chunks.append(chunk)
311+
312+
assert len(chunks) == 2
313+
# sse-starlette yields strings or bytes formatted as Server-Sent Events
314+
assert 'chunk1' in str(chunks[0])
315+
assert 'chunk2' in str(chunks[1])
316+
317+
async def test_on_subscribe_to_task_success(
318+
self, rest_dispatcher_instance
319+
):
320+
req = make_mock_request(method='GET', path_params={'id': 'test_task'})
321+
response = await rest_dispatcher_instance.on_subscribe_to_task(req)
322+
323+
assert response.status_code == 200
324+
325+
chunks = []
326+
async for chunk in response.body_iterator:
327+
chunks.append(chunk)
328+
329+
assert len(chunks) == 2
330+
assert 'chunk1' in str(chunks[0])
331+
assert 'chunk2' in str(chunks[1])

0 commit comments

Comments
 (0)