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.
This commit is contained in:
Teknium 2026-07-22 08:36:10 -07:00
parent a9818003fa
commit caa465752c
No known key found for this signature in database
2 changed files with 13 additions and 8 deletions

View file

@ -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):

View file

@ -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