Skip to content

Commit 3f7fc15

Browse files
committed
fix: fix error handling
1 parent fd12dff commit 3f7fc15

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

tests/integration/test_client_server_integration.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ def transport_setups(request) -> TransportSetup:
292292
return request.getfixturevalue(request.param)
293293

294294

295+
@pytest.fixture(
296+
params=[
297+
pytest.param('jsonrpc_setup', id='JSON-RPC'),
298+
pytest.param('rest_setup', id='REST'),
299+
]
300+
)
301+
def http_transport_setups(request) -> TransportSetup:
302+
"""Parametrized fixture that runs tests against HTTP-based transports only."""
303+
return request.getfixturevalue(request.param)
304+
305+
295306
# --- gRPC Setup ---
296307

297308

@@ -927,3 +938,62 @@ async def test_rest_malformed_payload(
927938
assert response.status_code == 400
928939

929940
await transport.close()
941+
942+
943+
@pytest.mark.asyncio
944+
async def test_validate_version_unsupported(http_transport_setups) -> None:
945+
"""Integration test for @validate_version decorator."""
946+
client = http_transport_setups.client
947+
948+
service_params = {'A2A-Version': '2.0.0'}
949+
context = ClientCallContext(service_parameters=service_params)
950+
951+
params = GetTaskRequest(id=GET_TASK_RESPONSE.id)
952+
953+
with pytest.raises(VersionNotSupportedError) as exc_info:
954+
await client.get_task(request=params, context=context)
955+
956+
assert 'not supported' in str(exc_info.value).lower()
957+
await client.close()
958+
959+
960+
@pytest.mark.asyncio
961+
async def test_validate_decorator_push_notifications_disabled(
962+
transport_setups, agent_card: AgentCard
963+
) -> None:
964+
"""Integration test for @validate decorator with push notifications disabled."""
965+
client = transport_setups.client
966+
967+
agent_card.capabilities.push_notifications = False
968+
969+
params = TaskPushNotificationConfig(task_id='123')
970+
971+
with pytest.raises(UnsupportedOperationError) as exc_info:
972+
await client.create_task_push_notification_config(request=params)
973+
974+
assert 'not supported' in str(exc_info.value).lower()
975+
await client.close()
976+
977+
978+
@pytest.mark.asyncio
979+
async def test_validate_async_generator_streaming_disabled(
980+
transport_setups, agent_card: AgentCard
981+
) -> None:
982+
"""Integration test for @validate_async_generator decorator when streaming is disabled."""
983+
client = transport_setups.client
984+
transport = client._transport
985+
986+
agent_card.capabilities.streaming = False
987+
988+
params = SendMessageRequest(
989+
message=Message(role=Role.ROLE_USER, parts=[Part(text='hi')])
990+
)
991+
992+
stream = transport.send_message_streaming(request=params)
993+
994+
with pytest.raises(UnsupportedOperationError) as exc_info:
995+
async for _ in stream:
996+
pass
997+
998+
assert 'not supported' in str(exc_info.value).lower()
999+
await transport.close()

0 commit comments

Comments
 (0)