Skip to content

Commit 5c10440

Browse files
committed
Update IDs to UUIDs
1 parent cbfd286 commit 5c10440

File tree

3 files changed

+101
-46
lines changed

3 files changed

+101
-46
lines changed

tests/server/apps/jsonrpc/test_serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_handle_unicode_characters(agent_card_with_api_key: AgentCard):
163163
'message': {
164164
'role': 'user',
165165
'parts': [{'kind': 'text', 'text': unicode_text}],
166-
'message_id': 'msg-unicode',
166+
'message_id': '9a875406-2ebb-43d7-82e6-9f7c14d51cce',
167167
}
168168
},
169169
}

tests/server/request_handlers/test_default_request_handler.py

Lines changed: 91 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ async def test_on_cancel_task_invalid_result_type():
292292
# Mock ResultAggregator to return a Message
293293
mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator)
294294
mock_result_aggregator_instance.consume_all.return_value = Message(
295-
message_id='unexpected_msg', role=Role.agent, parts=[]
295+
message_id='6e7579fb-eeeb-439d-8b94-0008c6a2c626',
296+
role=Role.agent,
297+
parts=[],
296298
)
297299

298300
request_handler = DefaultRequestHandler(
@@ -506,7 +508,7 @@ async def test_on_message_send_no_result_from_aggregator():
506508
mock_agent_executor = AsyncMock(spec=AgentExecutor)
507509
mock_request_context_builder = AsyncMock(spec=RequestContextBuilder)
508510

509-
task_id = 'no_result_task'
511+
task_id = '43b91701-0e3e-415b-b4bf-2d53eb23db81'
510512
# Mock _request_context_builder.build
511513
mock_request_context = MagicMock(spec=RequestContext)
512514
mock_request_context.task_id = task_id
@@ -558,8 +560,8 @@ async def test_on_message_send_task_id_mismatch():
558560
mock_agent_executor = AsyncMock(spec=AgentExecutor)
559561
mock_request_context_builder = AsyncMock(spec=RequestContextBuilder)
560562

561-
context_task_id = 'context_task_id_1'
562-
result_task_id = 'DIFFERENT_task_id_1' # Mismatch
563+
context_task_id = 'c65e1186-487b-4bd2-a7f3-ddc766a02783'
564+
result_task_id = 'b6d8d5df-2da3-4f86-a173-388ed8654584' # Mismatch
563565

564566
# Mock _request_context_builder.build
565567
mock_request_context = MagicMock(spec=RequestContext)
@@ -687,7 +689,7 @@ async def test_on_message_send_interrupted_flow():
687689
mock_agent_executor = AsyncMock(spec=AgentExecutor)
688690
mock_request_context_builder = AsyncMock(spec=RequestContextBuilder)
689691

690-
task_id = 'interrupted_task_1'
692+
task_id = '6a24e838-b6cb-4ccb-aab1-09b57ec28256'
691693
# Mock _request_context_builder.build
692694
mock_request_context = MagicMock(spec=RequestContext)
693695
mock_request_context.task_id = task_id
@@ -699,7 +701,11 @@ async def test_on_message_send_interrupted_flow():
699701
request_context_builder=mock_request_context_builder,
700702
)
701703
params = MessageSendParams(
702-
message=Message(role=Role.user, message_id='21b34182-195d-467a-9ed5-3160c8acd8f5', parts=[])
704+
message=Message(
705+
role=Role.user,
706+
message_id='21b34182-195d-467a-9ed5-3160c8acd8f5',
707+
parts=[],
708+
)
703709
)
704710

705711
mock_result_aggregator_instance = AsyncMock(spec=ResultAggregator)
@@ -792,7 +798,7 @@ async def test_on_message_send_stream_with_push_notification():
792798
params = MessageSendParams(
793799
message=Message(
794800
role=Role.user,
795-
message_id='msg_stream_push',
801+
message_id='cffc8e42-0016-40e1-99ba-3e588923312c',
796802
parts=[],
797803
task_id=task_id,
798804
context_id=context_id,
@@ -1034,8 +1040,8 @@ async def test_on_message_send_stream_task_id_mismatch():
10341040
) # Only need a basic mock
10351041
mock_request_context_builder = AsyncMock(spec=RequestContextBuilder)
10361042

1037-
context_task_id = 'stream_task_id_ctx'
1038-
mismatched_task_id = 'DIFFERENT_stream_task_id'
1043+
context_task_id = 'dc1d1c1e-0b5b-45d1-a70e-47faafb2adff'
1044+
mismatched_task_id = '677cb217-5841-475c-9f45-06c3f8914f65'
10391045

10401046
mock_request_context = MagicMock(spec=RequestContext)
10411047
mock_request_context.task_id = context_task_id
@@ -1048,7 +1054,9 @@ async def test_on_message_send_stream_task_id_mismatch():
10481054
)
10491055
params = MessageSendParams(
10501056
message=Message(
1051-
role=Role.user, message_id='b990eddf-01d6-414d-90cb-02f8549debe9', parts=[]
1057+
role=Role.user,
1058+
message_id='b990eddf-01d6-414d-90cb-02f8549debe9',
1059+
parts=[],
10521060
)
10531061
)
10541062

@@ -1097,7 +1105,7 @@ async def test_cleanup_producer_task_id_not_in_running_agents():
10971105
queue_manager=mock_queue_manager,
10981106
)
10991107

1100-
task_id = 'task_already_cleaned'
1108+
task_id = 'f7075439-b5c9-4286-a09a-a7a2d2756a03'
11011109

11021110
# Create a real, completed asyncio.Task for the test
11031111
async def dummy_coro_for_task():
@@ -1352,7 +1360,10 @@ async def test_get_task_push_notification_config_info_with_config_no_id():
13521360
result.push_notification_config.url
13531361
== set_config_params.push_notification_config.url
13541362
)
1355-
assert result.push_notification_config.id == '0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1363+
assert (
1364+
result.push_notification_config.id
1365+
== '0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1366+
)
13561367

13571368

13581369
@pytest.mark.asyncio
@@ -1376,14 +1387,18 @@ async def test_on_resubscribe_to_task_task_not_found():
13761387
pass
13771388

13781389
assert isinstance(exc_info.value.error, TaskNotFoundError)
1379-
mock_task_store.get.assert_awaited_once_with('8c897b3f-89a8-4692-aa72-4c33367d27b8')
1390+
mock_task_store.get.assert_awaited_once_with(
1391+
'8c897b3f-89a8-4692-aa72-4c33367d27b8'
1392+
)
13801393

13811394

13821395
@pytest.mark.asyncio
13831396
async def test_on_resubscribe_to_task_queue_not_found():
13841397
"""Test on_resubscribe_to_task when the queue is not found by queue_manager.tap."""
13851398
mock_task_store = AsyncMock(spec=TaskStore)
1386-
sample_task = create_sample_task(task_id='306589b7-57f8-48a0-8b8c-d1ab5aa237e0')
1399+
sample_task = create_sample_task(
1400+
task_id='306589b7-57f8-48a0-8b8c-d1ab5aa237e0'
1401+
)
13871402
mock_task_store.get.return_value = sample_task
13881403

13891404
mock_queue_manager = AsyncMock(spec=QueueManager)
@@ -1407,8 +1422,12 @@ async def test_on_resubscribe_to_task_queue_not_found():
14071422
assert isinstance(
14081423
exc_info.value.error, TaskNotFoundError
14091424
) # Should be TaskNotFoundError as per spec
1410-
mock_task_store.get.assert_awaited_once_with('306589b7-57f8-48a0-8b8c-d1ab5aa237e0')
1411-
mock_queue_manager.tap.assert_awaited_once_with('306589b7-57f8-48a0-8b8c-d1ab5aa237e0')
1425+
mock_task_store.get.assert_awaited_once_with(
1426+
'306589b7-57f8-48a0-8b8c-d1ab5aa237e0'
1427+
)
1428+
mock_queue_manager.tap.assert_awaited_once_with(
1429+
'306589b7-57f8-48a0-8b8c-d1ab5aa237e0'
1430+
)
14121431

14131432

14141433
@pytest.mark.asyncio
@@ -1535,22 +1554,28 @@ async def test_list_task_push_notification_config_info_with_config():
15351554
mock_task_store.get.return_value = sample_task
15361555

15371556
push_config1 = PushNotificationConfig(
1538-
id='config_1', url='http://example.com'
1557+
id='37d6af86-231f-40a5-8dba-02d2ccb4e161', url='http://example.com'
15391558
)
15401559
push_config2 = PushNotificationConfig(
1541-
id='config_2', url='http://example.com'
1560+
id='86d0a728-e0f5-4a5c-af2d-e43bd116780c', url='http://example.com'
15421561
)
15431562

15441563
push_store = InMemoryPushNotificationConfigStore()
1545-
await push_store.set_info('0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config1)
1546-
await push_store.set_info('0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config2)
1564+
await push_store.set_info(
1565+
'0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config1
1566+
)
1567+
await push_store.set_info(
1568+
'0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config2
1569+
)
15471570

15481571
request_handler = DefaultRequestHandler(
15491572
agent_executor=DummyAgentExecutor(),
15501573
task_store=mock_task_store,
15511574
push_config_store=push_store,
15521575
)
1553-
params = ListTaskPushNotificationConfigParams(id='0a9970e3-0cdd-4726-899f-a1dfef92bd64')
1576+
params = ListTaskPushNotificationConfigParams(
1577+
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1578+
)
15541579

15551580
result: list[
15561581
TaskPushNotificationConfig
@@ -1599,7 +1624,9 @@ async def test_list_task_push_notification_config_info_with_config_and_no_id():
15991624
set_config_params2, create_server_call_context()
16001625
)
16011626

1602-
params = ListTaskPushNotificationConfigParams(id='0a9970e3-0cdd-4726-899f-a1dfef92bd64')
1627+
params = ListTaskPushNotificationConfigParams(
1628+
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1629+
)
16031630

16041631
result: list[
16051632
TaskPushNotificationConfig
@@ -1613,7 +1640,10 @@ async def test_list_task_push_notification_config_info_with_config_and_no_id():
16131640
result[0].push_notification_config.url
16141641
== set_config_params2.push_notification_config.url
16151642
)
1616-
assert str(result[0].push_notification_config.id) == '0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1643+
assert (
1644+
str(result[0].push_notification_config.id)
1645+
== '0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1646+
)
16171647

16181648

16191649
@pytest.mark.asyncio
@@ -1672,13 +1702,17 @@ async def test_delete_no_task_push_notification_config_info():
16721702
"""Test on_delete_task_push_notification_config without config info"""
16731703
mock_task_store = AsyncMock(spec=TaskStore)
16741704

1675-
sample_task = create_sample_task(task_id='0a9970e3-0cdd-4726-899f-a1dfef92bd64')
1705+
sample_task = create_sample_task(
1706+
task_id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1707+
)
16761708
mock_task_store.get.return_value = sample_task
16771709

16781710
push_store = InMemoryPushNotificationConfigStore()
16791711
await push_store.set_info(
16801712
'task_2',
1681-
PushNotificationConfig(id='config_1', url='http://example.com'),
1713+
PushNotificationConfig(
1714+
id='37d6af86-231f-40a5-8dba-02d2ccb4e161', url='http://example.com'
1715+
),
16821716
)
16831717

16841718
request_handler = DefaultRequestHandler(
@@ -1688,7 +1722,7 @@ async def test_delete_no_task_push_notification_config_info():
16881722
)
16891723
params = DeleteTaskPushNotificationConfigParams(
16901724
id='13d5b8a8-62d7-4490-98c8-d3951b42702a',
1691-
push_notification_config_id='config_non_existant',
1725+
push_notification_config_id='fb0133f8-0cf7-4e3e-adab-d65b8df0ae22',
16921726
)
16931727

16941728
result = await request_handler.on_delete_task_push_notification_config(
@@ -1697,7 +1731,8 @@ async def test_delete_no_task_push_notification_config_info():
16971731
assert result is None
16981732

16991733
params = DeleteTaskPushNotificationConfigParams(
1700-
id='task2', push_notification_config_id='config_non_existant'
1734+
id='c20360a1-201f-46d0-9e1d-5d5a6cb2601c',
1735+
push_notification_config_id='fb0133f8-0cf7-4e3e-adab-d65b8df0ae22',
17011736
)
17021737

17031738
result = await request_handler.on_delete_task_push_notification_config(
@@ -1717,15 +1752,19 @@ async def test_delete_task_push_notification_config_info_with_config():
17171752
mock_task_store.get.return_value = sample_task
17181753

17191754
push_config1 = PushNotificationConfig(
1720-
id='config_1', url='http://example.com'
1755+
id='37d6af86-231f-40a5-8dba-02d2ccb4e161', url='http://example.com'
17211756
)
17221757
push_config2 = PushNotificationConfig(
1723-
id='config_2', url='http://example.com'
1758+
id='86d0a728-e0f5-4a5c-af2d-e43bd116780c', url='http://example.com'
17241759
)
17251760

17261761
push_store = InMemoryPushNotificationConfigStore()
1727-
await push_store.set_info('0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config1)
1728-
await push_store.set_info('0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config2)
1762+
await push_store.set_info(
1763+
'0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config1
1764+
)
1765+
await push_store.set_info(
1766+
'0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config2
1767+
)
17291768
await push_store.set_info('task_2', push_config1)
17301769

17311770
request_handler = DefaultRequestHandler(
@@ -1734,7 +1773,8 @@ async def test_delete_task_push_notification_config_info_with_config():
17341773
push_config_store=push_store,
17351774
)
17361775
params = DeleteTaskPushNotificationConfigParams(
1737-
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_notification_config_id='config_1'
1776+
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64',
1777+
push_notification_config_id='37d6af86-231f-40a5-8dba-02d2ccb4e161',
17381778
)
17391779

17401780
result1 = await request_handler.on_delete_task_push_notification_config(
@@ -1744,7 +1784,9 @@ async def test_delete_task_push_notification_config_info_with_config():
17441784
assert result1 is None
17451785

17461786
result2 = await request_handler.on_list_task_push_notification_config(
1747-
ListTaskPushNotificationConfigParams(id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'),
1787+
ListTaskPushNotificationConfigParams(
1788+
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1789+
),
17481790
create_server_call_context(),
17491791
)
17501792

@@ -1767,16 +1809,21 @@ async def test_delete_task_push_notification_config_info_with_config_and_no_id()
17671809

17681810
# insertion without id should replace the existing config
17691811
push_store = InMemoryPushNotificationConfigStore()
1770-
await push_store.set_info('0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config)
1771-
await push_store.set_info('0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config)
1812+
await push_store.set_info(
1813+
'0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config
1814+
)
1815+
await push_store.set_info(
1816+
'0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_config
1817+
)
17721818

17731819
request_handler = DefaultRequestHandler(
17741820
agent_executor=DummyAgentExecutor(),
17751821
task_store=mock_task_store,
17761822
push_config_store=push_store,
17771823
)
17781824
params = DeleteTaskPushNotificationConfigParams(
1779-
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64', push_notification_config_id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1825+
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64',
1826+
push_notification_config_id='0a9970e3-0cdd-4726-899f-a1dfef92bd64',
17801827
)
17811828

17821829
result = await request_handler.on_delete_task_push_notification_config(
@@ -1786,7 +1833,9 @@ async def test_delete_task_push_notification_config_info_with_config_and_no_id()
17861833
assert result is None
17871834

17881835
result2 = await request_handler.on_list_task_push_notification_config(
1789-
ListTaskPushNotificationConfigParams(id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'),
1836+
ListTaskPushNotificationConfigParams(
1837+
id='0a9970e3-0cdd-4726-899f-a1dfef92bd64'
1838+
),
17901839
create_server_call_context(),
17911840
)
17921841

@@ -1805,7 +1854,7 @@ async def test_delete_task_push_notification_config_info_with_config_and_no_id()
18051854
@pytest.mark.parametrize('terminal_state', TERMINAL_TASK_STATES)
18061855
async def test_on_message_send_task_in_terminal_state(terminal_state):
18071856
"""Test on_message_send when task is already in a terminal state."""
1808-
task_id = f'terminal_task_{terminal_state.value}'
1857+
task_id = '5520dd18-ad0a-4307-a295-c4c93b543932'
18091858
terminal_task = create_sample_task(
18101859
task_id=task_id, status_state=terminal_state
18111860
)
@@ -1822,7 +1871,7 @@ async def test_on_message_send_task_in_terminal_state(terminal_state):
18221871
params = MessageSendParams(
18231872
message=Message(
18241873
role=Role.user,
1825-
message_id='msg_terminal',
1874+
message_id='4d1249a9-e290-4b55-8e16-691b060bedb1',
18261875
parts=[],
18271876
task_id=task_id,
18281877
)
@@ -1852,7 +1901,7 @@ async def test_on_message_send_task_in_terminal_state(terminal_state):
18521901
@pytest.mark.parametrize('terminal_state', TERMINAL_TASK_STATES)
18531902
async def test_on_message_send_stream_task_in_terminal_state(terminal_state):
18541903
"""Test on_message_send_stream when task is already in a terminal state."""
1855-
task_id = f'terminal_stream_task_{terminal_state.value}'
1904+
task_id = 'f7075439-b5c9-4286-a09a-a7a2d2756a03'
18561905
terminal_task = create_sample_task(
18571906
task_id=task_id, status_state=terminal_state
18581907
)
@@ -1866,7 +1915,7 @@ async def test_on_message_send_stream_task_in_terminal_state(terminal_state):
18661915
params = MessageSendParams(
18671916
message=Message(
18681917
role=Role.user,
1869-
message_id='msg_terminal_stream',
1918+
message_id='4d1249a9-e290-4b55-8e16-691b060bedb1',
18701919
parts=[],
18711920
task_id=task_id,
18721921
)
@@ -1896,7 +1945,7 @@ async def test_on_message_send_stream_task_in_terminal_state(terminal_state):
18961945
@pytest.mark.parametrize('terminal_state', TERMINAL_TASK_STATES)
18971946
async def test_on_resubscribe_to_task_in_terminal_state(terminal_state):
18981947
"""Test on_resubscribe_to_task when task is in a terminal state."""
1899-
task_id = f'resub_terminal_task_{terminal_state.value}'
1948+
task_id = 'a12bb281-c7ab-491f-8b3f-9913addca78a'
19001949
terminal_task = create_sample_task(
19011950
task_id=task_id, status_state=terminal_state
19021951
)

0 commit comments

Comments
 (0)