test: use real Slack session entries for reset removal
This commit is contained in:
@@ -2987,9 +2987,16 @@ class TestThreadReplyHandling:
|
||||
self, adapter_with_session_store, mock_session_store
|
||||
):
|
||||
"""Thread replies without mention should be processed if there's an active session."""
|
||||
# Simulate an active session for this thread
|
||||
from gateway.session import SessionEntry
|
||||
|
||||
# Deserialize a legacy routing entry so lifecycle flags have real defaults.
|
||||
session_key = "agent:main:slack:group:T_TEAM:C123:123.000:U_USER"
|
||||
mock_session_store._entries = {session_key: MagicMock()}
|
||||
mock_session_store._entries = {session_key: SessionEntry.from_dict({
|
||||
"session_key": session_key,
|
||||
"session_id": "slack-thread-session",
|
||||
"created_at": "2024-01-01T00:00:00",
|
||||
"updated_at": "2024-01-01T00:00:00",
|
||||
})}
|
||||
|
||||
event = {
|
||||
"text": "Follow-up question",
|
||||
|
||||
@@ -515,17 +515,31 @@ class TestSessionKeyChatType:
|
||||
This is the exact bug that the old ``hardcoded "group"`` code caused:
|
||||
the lookup builds ``group:…`` while the real session is ``dm:…``.
|
||||
"""
|
||||
from gateway.session import SessionEntry
|
||||
|
||||
adapter = _make_adapter()
|
||||
mock_store = MagicMock()
|
||||
mock_store._entries = {
|
||||
"agent:main:slack:dm:D0DMCHANNEL:2000.0": MagicMock()
|
||||
}
|
||||
session_key = "agent:main:slack:dm:D0DMCHANNEL:2000.0"
|
||||
mock_store._entries = {session_key: SessionEntry.from_dict({
|
||||
"session_key": session_key,
|
||||
"session_id": "slack-dm-thread-session",
|
||||
"created_at": "2024-01-01T00:00:00",
|
||||
"updated_at": "2024-01-01T00:00:00",
|
||||
})}
|
||||
mock_store._ensure_loaded = MagicMock()
|
||||
mock_store.config = MagicMock()
|
||||
mock_store.config.group_sessions_per_user = True
|
||||
mock_store.config.thread_sessions_per_user = False
|
||||
adapter._session_store = mock_store
|
||||
|
||||
# The same entry must be active with the event's correct DM type.
|
||||
assert adapter._has_active_session_for_thread(
|
||||
channel_id="D0DMCHANNEL",
|
||||
thread_ts="2000.0",
|
||||
user_id="U_USER",
|
||||
chat_type="dm",
|
||||
)
|
||||
|
||||
# Default chat_type="group" should NOT find the DM session
|
||||
result = adapter._has_active_session_for_thread(
|
||||
channel_id="D0DMCHANNEL",
|
||||
|
||||
Reference in New Issue
Block a user