Skip to content

Commit 80a6c9f

Browse files
committed
format
1 parent 749d102 commit 80a6c9f

3 files changed

Lines changed: 47 additions & 19 deletions

File tree

tests/integration/test_client_server_integration.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
create_rest_routes,
3333
)
3434
from a2a.server.request_handlers import GrpcHandler, RequestHandler
35-
from a2a.server.request_handlers.default_request_handler import DefaultRequestHandler
35+
from a2a.server.request_handlers.default_request_handler import (
36+
DefaultRequestHandler,
37+
)
3638
from a2a.types import a2a_pb2_grpc
3739
from a2a.types.a2a_pb2 import (
3840
AgentCapabilities,
@@ -1140,7 +1142,6 @@ async def test_validate_decorator_push_notifications_disabled(
11401142
url='http://example.com',
11411143
)
11421144

1143-
11441145
with pytest.raises(PushNotificationNotSupportedError) as exc_info:
11451146
await client.create_task_push_notification_config(request=params)
11461147

@@ -1163,8 +1164,12 @@ async def test_validate_streaming_disabled(
11631164
agent_card=agent_card,
11641165
)
11651166

1166-
error_handling_setups.handler.on_message_send_stream.side_effect = real_handler.on_message_send_stream
1167-
error_handling_setups.handler.on_subscribe_to_task.side_effect = real_handler.on_subscribe_to_task
1167+
error_handling_setups.handler.on_message_send_stream.side_effect = (
1168+
real_handler.on_message_send_stream
1169+
)
1170+
error_handling_setups.handler.on_subscribe_to_task.side_effect = (
1171+
real_handler.on_subscribe_to_task
1172+
)
11681173

11691174
params = SendMessageRequest(
11701175
message=Message(

tests/server/request_handlers/test_default_request_handler.py

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ def agent_card():
120120
return AgentCard(
121121
name='test_agent',
122122
version='1.0',
123-
capabilities=AgentCapabilities(
124-
streaming=True, push_notifications=True
125-
),
123+
capabilities=AgentCapabilities(streaming=True, push_notifications=True),
126124
)
127125

128126

@@ -610,7 +608,9 @@ async def mock_current_result():
610608

611609

612610
@pytest.mark.asyncio
613-
async def test_on_message_send_with_push_notification_in_non_blocking_request(agent_card):
611+
async def test_on_message_send_with_push_notification_in_non_blocking_request(
612+
agent_card,
613+
):
614614
"""Test that push notification callback is called during background event processing for non-blocking requests."""
615615
mock_task_store = AsyncMock(spec=TaskStore)
616616
mock_push_notification_store = AsyncMock(spec=PushNotificationConfigStore)
@@ -750,7 +750,9 @@ async def mock_consume_and_break_on_interrupt(
750750

751751

752752
@pytest.mark.asyncio
753-
async def test_on_message_send_with_push_notification_no_existing_Task(agent_card):
753+
async def test_on_message_send_with_push_notification_no_existing_Task(
754+
agent_card,
755+
):
754756
"""Test on_message_send for new task sets push notification info if provided."""
755757
mock_task_store = AsyncMock(spec=TaskStore)
756758
mock_push_notification_store = AsyncMock(spec=PushNotificationConfigStore)
@@ -1328,7 +1330,9 @@ async def to_coro(val):
13281330

13291331

13301332
@pytest.mark.asyncio
1331-
async def test_stream_disconnect_then_resubscribe_receives_future_events(agent_card):
1333+
async def test_stream_disconnect_then_resubscribe_receives_future_events(
1334+
agent_card,
1335+
):
13321336
"""Start streaming, disconnect, then resubscribe and ensure subsequent events are streamed."""
13331337
# Arrange
13341338
mock_task_store = AsyncMock(spec=TaskStore)
@@ -1420,7 +1424,9 @@ async def exec_side_effect(_request, queue: EventQueue):
14201424

14211425

14221426
@pytest.mark.asyncio
1423-
async def test_on_message_send_stream_client_disconnect_triggers_background_cleanup_and_producer_continues(agent_card):
1427+
async def test_on_message_send_stream_client_disconnect_triggers_background_cleanup_and_producer_continues(
1428+
agent_card,
1429+
):
14241430
"""Simulate client disconnect: stream stops early, cleanup is scheduled in background,
14251431
producer keeps running, and cleanup completes after producer finishes."""
14261432
# Arrange
@@ -2037,7 +2043,9 @@ async def test_get_task_push_notification_config_info_with_config(agent_card):
20372043

20382044

20392045
@pytest.mark.asyncio
2040-
async def test_get_task_push_notification_config_info_with_config_no_id(agent_card):
2046+
async def test_get_task_push_notification_config_info_with_config_no_id(
2047+
agent_card,
2048+
):
20412049
"""Test on_get_task_push_notification_config with no push config id"""
20422050
mock_task_store = AsyncMock(spec=TaskStore)
20432051
mock_task_store.get.return_value = Task(id='task_1', context_id='ctx_1')
@@ -2268,7 +2276,9 @@ async def test_list_task_push_notification_config_info_with_config(agent_card):
22682276

22692277

22702278
@pytest.mark.asyncio
2271-
async def test_list_task_push_notification_config_info_with_config_and_no_id(agent_card):
2279+
async def test_list_task_push_notification_config_info_with_config_and_no_id(
2280+
agent_card,
2281+
):
22722282
"""Test on_list_task_push_notification_configs with no push config id"""
22732283
mock_task_store = AsyncMock(spec=TaskStore)
22742284
mock_task_store.get.return_value = Task(id='task_1', context_id='ctx_1')
@@ -2398,7 +2408,9 @@ async def test_delete_no_task_push_notification_config_info(agent_card):
23982408

23992409

24002410
@pytest.mark.asyncio
2401-
async def test_delete_task_push_notification_config_info_with_config(agent_card):
2411+
async def test_delete_task_push_notification_config_info_with_config(
2412+
agent_card,
2413+
):
24022414
"""Test on_list_task_push_notification_configs with push config+id"""
24032415
mock_task_store = AsyncMock(spec=TaskStore)
24042416

@@ -2445,7 +2457,9 @@ async def test_delete_task_push_notification_config_info_with_config(agent_card)
24452457

24462458

24472459
@pytest.mark.asyncio
2448-
async def test_delete_task_push_notification_config_info_with_config_and_no_id(agent_card):
2460+
async def test_delete_task_push_notification_config_info_with_config_and_no_id(
2461+
agent_card,
2462+
):
24492463
"""Test on_list_task_push_notification_configs with no push config id"""
24502464
mock_task_store = AsyncMock(spec=TaskStore)
24512465

@@ -2494,7 +2508,9 @@ async def test_delete_task_push_notification_config_info_with_config_and_no_id(a
24942508

24952509
@pytest.mark.asyncio
24962510
@pytest.mark.parametrize('terminal_state', TERMINAL_TASK_STATES)
2497-
async def test_on_message_send_task_in_terminal_state(terminal_state, agent_card):
2511+
async def test_on_message_send_task_in_terminal_state(
2512+
terminal_state, agent_card
2513+
):
24982514
"""Test on_message_send when task is already in a terminal state."""
24992515
state_name = TaskState.Name(terminal_state)
25002516
task_id = f'terminal_task_{state_name}'
@@ -2540,7 +2556,9 @@ async def test_on_message_send_task_in_terminal_state(terminal_state, agent_card
25402556

25412557
@pytest.mark.asyncio
25422558
@pytest.mark.parametrize('terminal_state', TERMINAL_TASK_STATES)
2543-
async def test_on_message_send_stream_task_in_terminal_state(terminal_state, agent_card):
2559+
async def test_on_message_send_stream_task_in_terminal_state(
2560+
terminal_state, agent_card
2561+
):
25442562
"""Test on_message_send_stream when task is already in a terminal state."""
25452563
state_name = TaskState.Name(terminal_state)
25462564
task_id = f'terminal_stream_task_{state_name}'
@@ -2583,7 +2601,9 @@ async def test_on_message_send_stream_task_in_terminal_state(terminal_state, age
25832601

25842602
@pytest.mark.asyncio
25852603
@pytest.mark.parametrize('terminal_state', TERMINAL_TASK_STATES)
2586-
async def test_on_subscribe_to_task_in_terminal_state(terminal_state, agent_card):
2604+
async def test_on_subscribe_to_task_in_terminal_state(
2605+
terminal_state, agent_card
2606+
):
25872607
"""Test on_subscribe_to_task when task is in a terminal state."""
25882608
state_name = TaskState.Name(terminal_state)
25892609
task_id = f'resub_terminal_task_{state_name}'
@@ -2654,7 +2674,9 @@ async def test_on_message_send_task_id_provided_but_task_not_found(agent_card):
26542674

26552675

26562676
@pytest.mark.asyncio
2657-
async def test_on_message_send_stream_task_id_provided_but_task_not_found(agent_card):
2677+
async def test_on_message_send_stream_task_id_provided_but_task_not_found(
2678+
agent_card,
2679+
):
26582680
"""Test on_message_send_stream when task_id is provided but task doesn't exist."""
26592681
task_id = 'nonexistent_stream_task'
26602682
mock_task_store = AsyncMock(spec=TaskStore)

tests/server/request_handlers/test_grpc_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def grpc_handler(
5656
mock_request_handler.agent_card = sample_agent_card
5757
return GrpcHandler(request_handler=mock_request_handler)
5858

59+
5960
# --- Test Cases ---
6061

6162

0 commit comments

Comments
 (0)