Files

39 lines
1.0 KiB
Python

import datetime
import uuid
from agentmsgs.core.types import Agent, Thread
def test_agent_identity_on_id_not_name():
a1 = Agent(id=uuid.uuid4(), name="Alice")
a2 = Agent(id=uuid.uuid4(), name="Alice")
assert a1 != a2 # different id => not equal even though name same
assert hash(a1) != hash(a2)
def test_agent_hash_on_id():
uid = uuid.uuid4()
a1 = Agent(id=uid, name="Alice")
a2 = Agent(
id=uid, name="Bob"
) # same id, different name => equal per design (id is identity)
assert a1 == a2
assert hash(a1) == hash(a2)
def test_thread_multiple_with_same_participants_allowed():
a = Agent(id=uuid.uuid4(), name="A")
b = Agent(id=uuid.uuid4(), name="B")
t1 = Thread(
id=uuid.uuid4(),
participants=frozenset({a, b}),
created_at=datetime.datetime.now(datetime.UTC),
)
t2 = Thread(
id=uuid.uuid4(),
participants=frozenset({a, b}),
created_at=datetime.datetime.now(datetime.UTC),
)
assert t1 != t2
assert t1.participants == t2.participants