@@ -134,14 +134,13 @@ async def test_on_get_task_not_found():
134134 params = TaskQueryParams (id = 'non_existent_task' )
135135
136136 from a2a .utils .errors import ServerError # Local import for ServerError
137+
137138 context = create_server_call_context ()
138139 with pytest .raises (ServerError ) as exc_info :
139140 await request_handler .on_get_task (params , context )
140141
141142 assert isinstance (exc_info .value .error , TaskNotFoundError )
142- mock_task_store .get .assert_awaited_once_with (
143- 'non_existent_task' , context
144- )
143+ mock_task_store .get .assert_awaited_once_with ('non_existent_task' , context )
145144
146145
147146@pytest .mark .asyncio
@@ -156,16 +155,14 @@ async def test_on_cancel_task_task_not_found():
156155 params = TaskIdParams (id = 'task_not_found_for_cancel' )
157156
158157 from a2a .utils .errors import ServerError # Local import
158+
159159 context = create_server_call_context ()
160160 with pytest .raises (ServerError ) as exc_info :
161- await request_handler .on_cancel_task (
162- params , context
163- )
161+ await request_handler .on_cancel_task (params , context )
164162
165163 assert isinstance (exc_info .value .error , TaskNotFoundError )
166164 mock_task_store .get .assert_awaited_once_with (
167- 'task_not_found_for_cancel' ,
168- context
165+ 'task_not_found_for_cancel' , context
169166 )
170167
171168
@@ -206,13 +203,9 @@ async def test_on_cancel_task_queue_tap_returns_none():
206203 return_value = mock_result_aggregator_instance ,
207204 ):
208205 params = TaskIdParams (id = 'tap_none_task' )
209- result_task = await request_handler .on_cancel_task (
210- params , context
211- )
206+ result_task = await request_handler .on_cancel_task (params , context )
212207
213- mock_task_store .get .assert_awaited_once_with (
214- 'tap_none_task' , context
215- )
208+ mock_task_store .get .assert_awaited_once_with ('tap_none_task' , context )
216209 mock_queue_manager .tap .assert_awaited_once_with ('tap_none_task' )
217210 # agent_executor.cancel should be called with a new EventQueue if tap returned None
218211 mock_agent_executor .cancel .assert_awaited_once ()
@@ -264,9 +257,7 @@ async def test_on_cancel_task_cancels_running_agent():
264257 return_value = mock_result_aggregator_instance ,
265258 ):
266259 params = TaskIdParams (id = task_id )
267- await request_handler .on_cancel_task (
268- params , context
269- )
260+ await request_handler .on_cancel_task (params , context )
270261
271262 mock_producer_task .cancel .assert_called_once ()
272263 mock_agent_executor .cancel .assert_awaited_once ()
@@ -1280,16 +1271,15 @@ async def test_set_task_push_notification_config_task_not_found():
12801271 ),
12811272 )
12821273 from a2a .utils .errors import ServerError # Local import
1274+
12831275 context = create_server_call_context ()
12841276 with pytest .raises (ServerError ) as exc_info :
12851277 await request_handler .on_set_task_push_notification_config (
12861278 params , context
12871279 )
12881280
12891281 assert isinstance (exc_info .value .error , TaskNotFoundError )
1290- mock_task_store .get .assert_awaited_once_with (
1291- 'non_existent_task' , context
1292- )
1282+ mock_task_store .get .assert_awaited_once_with ('non_existent_task' , context )
12931283 mock_push_store .set_info .assert_not_awaited ()
12941284
12951285
@@ -1333,9 +1323,7 @@ async def test_get_task_push_notification_config_task_not_found():
13331323 )
13341324
13351325 assert isinstance (exc_info .value .error , TaskNotFoundError )
1336- mock_task_store .get .assert_awaited_once_with (
1337- 'non_existent_task' , context
1338- )
1326+ mock_task_store .get .assert_awaited_once_with ('non_existent_task' , context )
13391327 mock_push_store .get_info .assert_not_awaited ()
13401328
13411329
@@ -1357,6 +1345,7 @@ async def test_get_task_push_notification_config_info_not_found():
13571345 )
13581346 params = GetTaskPushNotificationConfigParams (id = 'non_existent_task' )
13591347 from a2a .utils .errors import ServerError # Local import
1348+
13601349 context = create_server_call_context ()
13611350 with pytest .raises (ServerError ) as exc_info :
13621351 await request_handler .on_get_task_push_notification_config (
@@ -1366,9 +1355,7 @@ async def test_get_task_push_notification_config_info_not_found():
13661355 assert isinstance (
13671356 exc_info .value .error , InternalError
13681357 ) # Current code raises InternalError
1369- mock_task_store .get .assert_awaited_once_with (
1370- 'non_existent_task' , context
1371- )
1358+ mock_task_store .get .assert_awaited_once_with ('non_existent_task' , context )
13721359 mock_push_store .get_info .assert_awaited_once_with ('non_existent_task' )
13731360
13741361
@@ -1467,12 +1454,11 @@ async def test_on_resubscribe_to_task_task_not_found():
14671454 params = TaskIdParams (id = 'resub_task_not_found' )
14681455
14691456 from a2a .utils .errors import ServerError # Local import
1457+
14701458 context = create_server_call_context ()
14711459 with pytest .raises (ServerError ) as exc_info :
14721460 # Need to consume the async generator to trigger the error
1473- async for _ in request_handler .on_resubscribe_to_task (
1474- params , context
1475- ):
1461+ async for _ in request_handler .on_resubscribe_to_task (params , context ):
14761462 pass
14771463
14781464 assert isinstance (exc_info .value .error , TaskNotFoundError )
@@ -1502,9 +1488,7 @@ async def test_on_resubscribe_to_task_queue_not_found():
15021488
15031489 context = create_server_call_context ()
15041490 with pytest .raises (ServerError ) as exc_info :
1505- async for _ in request_handler .on_resubscribe_to_task (
1506- params , context
1507- ):
1491+ async for _ in request_handler .on_resubscribe_to_task (params , context ):
15081492 pass
15091493
15101494 assert isinstance (
@@ -1585,16 +1569,15 @@ async def test_list_task_push_notification_config_task_not_found():
15851569 )
15861570 params = ListTaskPushNotificationConfigParams (id = 'non_existent_task' )
15871571 from a2a .utils .errors import ServerError # Local import
1572+
15881573 context = create_server_call_context ()
15891574 with pytest .raises (ServerError ) as exc_info :
15901575 await request_handler .on_list_task_push_notification_config (
15911576 params , context
15921577 )
15931578
15941579 assert isinstance (exc_info .value .error , TaskNotFoundError )
1595- mock_task_store .get .assert_awaited_once_with (
1596- 'non_existent_task' , context
1597- )
1580+ mock_task_store .get .assert_awaited_once_with ('non_existent_task' , context )
15981581 mock_push_store .get_info .assert_not_awaited ()
15991582
16001583
@@ -1747,16 +1730,15 @@ async def test_delete_task_push_notification_config_task_not_found():
17471730 id = 'non_existent_task' , push_notification_config_id = 'config1'
17481731 )
17491732 from a2a .utils .errors import ServerError # Local import
1733+
17501734 context = create_server_call_context ()
17511735 with pytest .raises (ServerError ) as exc_info :
17521736 await request_handler .on_delete_task_push_notification_config (
17531737 params , context
17541738 )
17551739
17561740 assert isinstance (exc_info .value .error , TaskNotFoundError )
1757- mock_task_store .get .assert_awaited_once_with (
1758- 'non_existent_task' , context
1759- )
1741+ mock_task_store .get .assert_awaited_once_with ('non_existent_task' , context )
17601742 mock_push_store .get_info .assert_not_awaited ()
17611743
17621744
@@ -2000,11 +1982,10 @@ async def test_on_resubscribe_to_task_in_terminal_state(terminal_state):
20001982 params = TaskIdParams (id = task_id )
20011983
20021984 from a2a .utils .errors import ServerError
1985+
20031986 context = create_server_call_context ()
20041987 with pytest .raises (ServerError ) as exc_info :
2005- async for _ in request_handler .on_resubscribe_to_task (
2006- params , context
2007- ):
1988+ async for _ in request_handler .on_resubscribe_to_task (params , context ):
20081989 pass # pragma: no cover
20091990
20101991 assert isinstance (exc_info .value .error , InvalidParamsError )
@@ -2013,9 +1994,7 @@ async def test_on_resubscribe_to_task_in_terminal_state(terminal_state):
20131994 f'Task { task_id } is in terminal state: { terminal_state .value } '
20141995 in exc_info .value .error .message
20151996 )
2016- mock_task_store .get .assert_awaited_once_with (
2017- task_id , context
2018- )
1997+ mock_task_store .get .assert_awaited_once_with (task_id , context )
20191998
20201999
20212000@pytest .mark .asyncio
0 commit comments