|
8 | 8 |
|
9 | 9 | from a2a.compat.v0_3 import a2a_v0_3_pb2, rest_adapter |
10 | 10 | from a2a.compat.v0_3.rest_adapter import REST03Adapter |
| 11 | +from a2a.compat.v0_3.rest_transport import CompatRestTransport |
11 | 12 | from a2a.server.request_handlers.request_handler import RequestHandler |
12 | 13 | from a2a.server.routes import create_agent_card_routes |
13 | 14 | from a2a.server.routes.rest_routes import create_rest_routes |
14 | 15 | from a2a.types.a2a_pb2 import ( |
15 | 16 | AgentCard, |
| 17 | + DeleteTaskPushNotificationConfigRequest, |
16 | 18 | Message as Message10, |
17 | 19 | Part as Part10, |
18 | 20 | Role as Role10, |
@@ -228,6 +230,69 @@ async def test_invalid_utf8_body_v03_is_bad_request( |
228 | 230 | assert response.json()['error']['status'] == 'INVALID_ARGUMENT' |
229 | 231 |
|
230 | 232 |
|
| 233 | +@pytest.mark.anyio |
| 234 | +async def test_delete_push_notification_config_v03( |
| 235 | + client: AsyncClient, request_handler: MagicMock |
| 236 | +) -> None: |
| 237 | + request_handler.on_delete_task_push_notification_config.return_value = None |
| 238 | + |
| 239 | + response = await client.delete( |
| 240 | + '/v1/tasks/test_task_id/pushNotificationConfigs/push-1' |
| 241 | + ) |
| 242 | + |
| 243 | + assert response.status_code == 200 |
| 244 | + assert response.json() == {} |
| 245 | + request_handler.on_delete_task_push_notification_config.assert_awaited_once() |
| 246 | + params = request_handler.on_delete_task_push_notification_config.call_args[ |
| 247 | + 0 |
| 248 | + ][0] |
| 249 | + assert params == DeleteTaskPushNotificationConfigRequest( |
| 250 | + task_id='test_task_id', id='push-1' |
| 251 | + ) |
| 252 | + |
| 253 | + |
| 254 | +@pytest.mark.anyio |
| 255 | +async def test_delete_push_notification_config_v03_unknown_task_returns_404( |
| 256 | + client: AsyncClient, request_handler: MagicMock |
| 257 | +) -> None: |
| 258 | + request_handler.on_delete_task_push_notification_config.side_effect = ( |
| 259 | + TaskNotFoundError |
| 260 | + ) |
| 261 | + |
| 262 | + response = await client.delete( |
| 263 | + '/v1/tasks/unknown/pushNotificationConfigs/push-1' |
| 264 | + ) |
| 265 | + |
| 266 | + assert response.status_code == 404 |
| 267 | + assert response.json()['error']['status'] == 'NOT_FOUND' |
| 268 | + |
| 269 | + |
| 270 | +@pytest.mark.anyio |
| 271 | +async def test_compat_rest_client_deletes_push_notification_config( |
| 272 | + client: AsyncClient, request_handler: MagicMock |
| 273 | +) -> None: |
| 274 | + request_handler.on_delete_task_push_notification_config.return_value = None |
| 275 | + transport = CompatRestTransport( |
| 276 | + httpx_client=client, |
| 277 | + agent_card=AgentCard(), |
| 278 | + url='http://testapp', |
| 279 | + ) |
| 280 | + |
| 281 | + await transport.delete_task_push_notification_config( |
| 282 | + DeleteTaskPushNotificationConfigRequest( |
| 283 | + task_id='test_task_id', id='push-1' |
| 284 | + ) |
| 285 | + ) |
| 286 | + |
| 287 | + request_handler.on_delete_task_push_notification_config.assert_awaited_once() |
| 288 | + params = request_handler.on_delete_task_push_notification_config.call_args[ |
| 289 | + 0 |
| 290 | + ][0] |
| 291 | + assert params == DeleteTaskPushNotificationConfigRequest( |
| 292 | + task_id='test_task_id', id='push-1' |
| 293 | + ) |
| 294 | + |
| 295 | + |
231 | 296 | @pytest.mark.anyio |
232 | 297 | async def test_list_tasks_not_in_v03_adapter_routes( |
233 | 298 | request_handler: RequestHandler, |
|
0 commit comments