Skip to content

Commit 35e228e

Browse files
committed
tests: lock collision-safe event ids in A2A converter coverage (#4567)
1 parent 223d9a7 commit 35e228e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/unittests/a2a/converters/test_event_converter.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from unittest.mock import Mock
1616
from unittest.mock import patch
17+
import uuid
1718

1819
from a2a.types import DataPart
1920
from a2a.types import Message
@@ -177,6 +178,20 @@ def test_get_context_metadata_none_context(self):
177178
_get_context_metadata(self.mock_event, None)
178179
assert "Invocation context cannot be None" in str(exc_info.value)
179180

181+
def test_event_new_id_uses_uuid4(self):
182+
"""Event IDs must be collision-safe random UUID4 values."""
183+
event_id = Event.new_id()
184+
parsed = uuid.UUID(event_id)
185+
186+
assert parsed.version == 4
187+
188+
def test_event_ids_are_unique_for_same_author(self):
189+
"""Events from the same author should not reuse normalized-name IDs."""
190+
events = [Event(author="same_author") for _ in range(64)]
191+
ids = {event.id for event in events}
192+
193+
assert len(ids) == len(events)
194+
180195
def test_create_artifact_id(self):
181196
"""Test artifact ID creation."""
182197
app_name = "test-app"

0 commit comments

Comments
 (0)