feat: add thread info and status reads
This commit is contained in:
16 files changed
+496
-33
No files matched your search
+26
-1
@@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from agentmsgs.core.types import Agent, Thread
|
||||
from agentmsgs.core.types import Agent, Message, Thread, ThreadInfo, ThreadReadState
|
||||
|
||||
|
||||
def test_agent_identity_on_id_not_name():
|
||||
@@ -36,3 +36,28 @@ def test_thread_multiple_with_same_participants_allowed():
|
||||
)
|
||||
assert t1 != t2
|
||||
assert t1.participants == t2.participants
|
||||
|
||||
|
||||
def test_thread_info_and_read_state_hold_derived_data():
|
||||
now = datetime.datetime.now(datetime.UTC)
|
||||
alice = Agent(id=uuid.uuid4(), name="Alice")
|
||||
bob = Agent(id=uuid.uuid4(), name="Bob")
|
||||
thread = Thread(
|
||||
id=uuid.uuid4(), participants=frozenset({alice, bob}), created_at=now
|
||||
)
|
||||
latest = Message(
|
||||
id=uuid.uuid4(), sender=bob, content="hello", seq=1, ts=now
|
||||
)
|
||||
info = ThreadInfo(thread=thread, message_count=1, latest_message=latest)
|
||||
state = ThreadReadState(
|
||||
agent=alice,
|
||||
cursor_seq=0,
|
||||
latest_seq=1,
|
||||
unread_count=1,
|
||||
unread_from_others_count=1,
|
||||
)
|
||||
|
||||
assert info.thread == thread
|
||||
assert info.latest_message == latest
|
||||
assert state.agent == alice
|
||||
assert state.unread_from_others_count == 1
|
||||
Reference in new issue
Block a user