Skip to content

Commit 65cdf3d

Browse files
Add tests for valid and invalid calls to
`task_push_notification_config_params`
1 parent b4fef7f commit 65cdf3d

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/utils/test_proto_utils.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,62 @@ def test_task_push_config_from_proto_invalid_parent(self):
244244
proto_utils.FromProto.task_push_notification_config(request)
245245
assert isinstance(exc_info.value.error, types.InvalidParamsError)
246246

247+
@pytest.mark.parametrize(
248+
'request_type, name, expected_task_id, expected_config_id',
249+
[
250+
(
251+
a2a_pb2.GetTaskPushNotificationConfigRequest,
252+
'tasks/task-123/pushNotificationConfigs/config-456',
253+
'task-123',
254+
'config-456',
255+
),
256+
(
257+
a2a_pb2.DeleteTaskPushNotificationConfigRequest,
258+
'tasks/task-abc/pushNotificationConfigs/config-def',
259+
'task-abc',
260+
'config-def',
261+
),
262+
],
263+
)
264+
def test_task_push_notification_config_params_valid(
265+
self, request_type, name, expected_task_id, expected_config_id
266+
):
267+
"""Test valid name in task_push_notification_config_params."""
268+
request = request_type(name=name)
269+
task_id, config_id = (
270+
proto_utils.ToProto.task_push_notification_config_params(request)
271+
)
272+
assert task_id == expected_task_id
273+
assert config_id == expected_config_id
274+
275+
@pytest.mark.parametrize(
276+
'request_type',
277+
[
278+
a2a_pb2.GetTaskPushNotificationConfigRequest,
279+
a2a_pb2.DeleteTaskPushNotificationConfigRequest,
280+
],
281+
)
282+
@pytest.mark.parametrize(
283+
'name',
284+
[
285+
'invalid-name-format',
286+
'tasks/task-123',
287+
'tasks/task-123/pushNotificationConfigs',
288+
'tasks//pushNotificationConfigs/config-456',
289+
'tasks/task-123/pushNotificationConfigs/',
290+
'foo/task-123/bar/config-456',
291+
],
292+
)
293+
def test_task_push_notification_config_params_invalid(
294+
self, request_type, name
295+
):
296+
"""Test invalid names in task_push_notification_config_params."""
297+
request = request_type(name=name)
298+
with pytest.raises(ServerError) as exc_info:
299+
proto_utils.ToProto.task_push_notification_config_params(request)
300+
assert isinstance(exc_info.value.error, types.InvalidParamsError)
301+
assert 'No task or config id for' in exc_info.value.error.message
302+
247303
def test_none_handling(self):
248304
"""Test that None inputs are handled gracefully."""
249305
assert proto_utils.ToProto.message(None) is None

0 commit comments

Comments
 (0)