From caa465752c5908de5e571099738e8da62fcd9473 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 22 Jul 2026 08:36:10 -0700 Subject: [PATCH] test(slack): adapt salvaged tests to current main - test_thread_command_skips_context_prefix: post-#69320 thread context IS fetched on first thread entry but rides channel_context; assert the command token stays at char zero and the backfill is preserved, instead of asserting the fetch never happens. - test_slack_send_retry.py: main's _get_client() now takes team_id; update the lambda stubs. --- tests/gateway/test_slack.py | 11 ++++++++--- tests/gateway/test_slack_send_retry.py | 10 +++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/gateway/test_slack.py b/tests/gateway/test_slack.py index faa6502e6121..b5da3e8bfc50 100644 --- a/tests/gateway/test_slack.py +++ b/tests/gateway/test_slack.py @@ -1804,11 +1804,15 @@ class TestBangPrefixCommands: @pytest.mark.asyncio async def test_thread_command_skips_context_prefix(self, adapter): + """Thread backfill must never prefix a mentioned command's text. + + Post-#69320, thread context IS fetched on first thread entry, but it + rides MessageEvent.channel_context — the command token must stay at + character zero of ``text``. + """ adapter._has_active_session_for_thread = MagicMock(return_value=False) adapter._fetch_thread_context = AsyncMock( - side_effect=AssertionError( - "_fetch_thread_context must not be called for slash commands" - ) + return_value="[Thread context]\nAlice: earlier\n" ) evt = self._make_event( "<@U_BOT> !new", @@ -1821,6 +1825,7 @@ class TestBangPrefixCommands: msg_event = adapter.handle_message.call_args[0][0] assert msg_event.text == "/new" assert msg_event.message_type == MessageType.COMMAND + assert msg_event.channel_context == "[Thread context]\nAlice: earlier\n" @pytest.mark.asyncio async def test_mention_command_drops_rich_text_command_arguments(self, adapter): diff --git a/tests/gateway/test_slack_send_retry.py b/tests/gateway/test_slack_send_retry.py index c6cb13582d25..dcfa6f1f0152 100644 --- a/tests/gateway/test_slack_send_retry.py +++ b/tests/gateway/test_slack_send_retry.py @@ -90,7 +90,7 @@ class TestSlackSendRetryable: client.chat_postMessage = AsyncMock( side_effect=_slack_api_error(429, retry_after="30") ) - adapter._get_client = lambda cid: client + adapter._get_client = lambda cid, team_id="": client result = await adapter.send("C123", "hello") assert not result.success @@ -104,7 +104,7 @@ class TestSlackSendRetryable: client.chat_postMessage = AsyncMock( side_effect=_slack_api_error(429) ) - adapter._get_client = lambda cid: client + adapter._get_client = lambda cid, team_id="": client result = await adapter.send("C123", "hello") assert not result.success @@ -118,7 +118,7 @@ class TestSlackSendRetryable: client.chat_postMessage = AsyncMock( side_effect=_slack_api_error(500) ) - adapter._get_client = lambda cid: client + adapter._get_client = lambda cid, team_id="": client result = await adapter.send("C123", "hello") assert not result.success @@ -132,7 +132,7 @@ class TestSlackSendRetryable: client.chat_postMessage = AsyncMock( side_effect=_slack_api_error(403) ) - adapter._get_client = lambda cid: client + adapter._get_client = lambda cid, team_id="": client result = await adapter.send("C123", "hello") assert not result.success @@ -145,7 +145,7 @@ class TestSlackSendRetryable: client.chat_postMessage = AsyncMock( side_effect=ConnectionError("Connection reset by peer") ) - adapter._get_client = lambda cid: client + adapter._get_client = lambda cid, team_id="": client result = await adapter.send("C123", "hello") assert not result.success