refactor(sessions)!: retire the global shared session (#6621)
Co-authored-by: chengyongru <chengyongru.ai@gmail.com>
This commit is contained in:
1 parent
28d73b6942
commit
e6b0aec2a8
77 files changed
+311
-1255
No files matched your search
@@ -8,7 +8,6 @@ import pytest
|
||||
from nanobot.bus.events import InboundMessage
|
||||
from nanobot.command.application import build_help_text, register_builtin_commands
|
||||
from nanobot.command.router import CommandContext, CommandRouter
|
||||
from nanobot.session.keys import UNIFIED_SESSION_KEY
|
||||
from nanobot.triggers.local_store import LocalTriggerStore
|
||||
|
||||
|
||||
@@ -47,7 +46,7 @@ async def test_trigger_command_creates_session_bound_local_trigger(tmp_path: Pat
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger_command_binds_inbound_session_when_unified_session_is_active(
|
||||
async def test_trigger_command_binds_explicit_topic_session(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
router = CommandRouter()
|
||||
@@ -55,16 +54,16 @@ async def test_trigger_command_binds_inbound_session_when_unified_session_is_act
|
||||
store = LocalTriggerStore(tmp_path)
|
||||
loop = SimpleNamespace(workspace=tmp_path, local_trigger_store=store)
|
||||
msg = InboundMessage(
|
||||
channel="websocket",
|
||||
channel="telegram",
|
||||
sender_id="user",
|
||||
chat_id="chat-1",
|
||||
content="/trigger PR review",
|
||||
session_key_override="websocket:chat-1:thread-a",
|
||||
session_key_override="telegram:chat-1:topic:5",
|
||||
)
|
||||
ctx = CommandContext(
|
||||
msg=msg,
|
||||
session=None,
|
||||
key=UNIFIED_SESSION_KEY,
|
||||
key=msg.session_key,
|
||||
raw="/trigger PR review",
|
||||
loop=loop,
|
||||
)
|
||||
@@ -72,9 +71,9 @@ async def test_trigger_command_binds_inbound_session_when_unified_session_is_act
|
||||
response = await router.dispatch(ctx)
|
||||
|
||||
assert response is not None
|
||||
trigger = store.list_for_session("websocket:chat-1:thread-a")[0]
|
||||
assert trigger.session_key == "websocket:chat-1:thread-a"
|
||||
assert store.list_for_session(UNIFIED_SESSION_KEY) == []
|
||||
trigger = store.list_for_session("telegram:chat-1:topic:5")[0]
|
||||
assert trigger.session_key == "telegram:chat-1:topic:5"
|
||||
assert store.list_for_session("telegram:chat-1") == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in new issue
Block a user