test(gateway): pin source.profile=None on MagicMock fixtures hitting _adapter_for_source

The routing sweep sends these paths through _adapter_for_source, which
reads source.profile. A bare MagicMock auto-attribute is truthy, so the
fixtures looked like stamped secondary profiles and hit the new
fail-closed branch. Real SessionSource.profile is None or str
(AGENTS.md pitfall #17).
This commit is contained in:
teknium1 2026-07-05 20:27:09 -07:00 committed by Teknium
parent f600dfca96
commit f761fb9d6a
2 changed files with 8 additions and 2 deletions

View file

@ -107,6 +107,10 @@ def _make_source(platform_value="telegram", chat_id="555", user_id="u1"):
src.platform = plat
src.chat_id = chat_id
src.user_id = user_id
# Real SessionSource.profile is None (single-profile) or a str; a MagicMock
# auto-attribute would read as a truthy "stamped profile" and trip the
# fail-closed path in _adapter_for_source (see AGENTS.md pitfall #17).
src.profile = None
return src

View file

@ -382,7 +382,9 @@ class TestBusyInputModeQueueFifo:
return runner, adapter
def _text_event(self, text: str) -> MessageEvent:
source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM)
# profile=None: a MagicMock auto-attribute reads as a truthy stamped
# profile and trips fail-closed adapter resolution (AGENTS.md #17).
source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM, profile=None)
return MessageEvent(
text=text,
message_type=MessageType.TEXT,
@ -433,7 +435,7 @@ class TestBusyInputModeQueueFifo:
runner, adapter = self._make_runner_and_adapter()
session_key = "telegram:user:burst"
source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM)
source = MagicMock(chat_id="c1", platform=Platform.TELEGRAM, profile=None)
for i in range(3):
runner._queue_or_replace_pending_event(
session_key,