fix(tests): eliminate AsyncMock unawaited-coroutine warnings in slack tests #35
@@ -77,6 +77,14 @@ def adapter():
|
||||
# Mock the Slack app client
|
||||
a._app = MagicMock()
|
||||
a._app.client = AsyncMock()
|
||||
# Default return values for methods called during _handle_slack_message
|
||||
# to avoid "coroutine 'AsyncMockMixin._execute_mock_call' was never awaited"
|
||||
# when the code does result.get(...) on a bare AsyncMock.
|
||||
a._app.client.users_info = AsyncMock(
|
||||
return_value={"user": {"name": "testuser", "real_name": "Test User"}}
|
||||
)
|
||||
a._app.client.conversations_replies = AsyncMock(return_value={"messages": []})
|
||||
a._app.client.chat_postMessage = AsyncMock(return_value={"ts": "1234.5678"})
|
||||
a._bot_user_id = "U_BOT"
|
||||
a._running = True
|
||||
# Capture events instead of processing them
|
||||
@@ -1860,6 +1868,13 @@ class TestThreadReplyHandling:
|
||||
a = SlackAdapter(config)
|
||||
a._app = MagicMock()
|
||||
a._app.client = AsyncMock()
|
||||
# Default return values for methods called during _handle_slack_message
|
||||
# to avoid "coroutine 'AsyncMockMixin._execute_mock_call' was never awaited"
|
||||
# when the code does result.get(...) on a bare AsyncMock.
|
||||
a._app.client.users_info = AsyncMock(
|
||||
return_value={"user": {"name": "testuser", "real_name": "Test User"}}
|
||||
)
|
||||
a._app.client.conversations_replies = AsyncMock(return_value={"messages": []})
|
||||
a._bot_user_id = "U_BOT"
|
||||
a._team_bot_user_ids = {"T_TEAM": "U_BOT"}
|
||||
a._running = True
|
||||
@@ -2000,6 +2015,12 @@ class TestAssistantThreadLifecycle:
|
||||
a = SlackAdapter(config)
|
||||
a._app = MagicMock()
|
||||
a._app.client = AsyncMock()
|
||||
# Default return values to avoid "coroutine 'AsyncMockMixin._execute_mock_call'
|
||||
# was never awaited" when code does result.get(...) on a bare AsyncMock.
|
||||
a._app.client.users_info = AsyncMock(
|
||||
return_value={"user": {"name": "testuser", "real_name": "Test User"}}
|
||||
)
|
||||
a._app.client.conversations_replies = AsyncMock(return_value={"messages": []})
|
||||
a._bot_user_id = "U_BOT"
|
||||
a._team_bot_user_ids = {"T_TEAM": "U_BOT"}
|
||||
a._running = True
|
||||
|
||||
@@ -56,6 +56,14 @@ def _make_adapter():
|
||||
adapter._team_clients = {"T1": AsyncMock()}
|
||||
adapter._team_bot_user_ids = {"T1": "U_BOT"}
|
||||
adapter._channel_team = {"C1": "T1"}
|
||||
# Default return values to avoid "coroutine 'AsyncMockMixin._execute_mock_call'
|
||||
# was never awaited" when code does result.get(...) on a bare AsyncMock.
|
||||
adapter._team_clients["T1"].users_info = AsyncMock(
|
||||
return_value={"user": {"name": "testuser", "real_name": "Test User"}}
|
||||
)
|
||||
adapter._team_clients["T1"].conversations_replies = AsyncMock(
|
||||
return_value={"messages": []}
|
||||
)
|
||||
return adapter
|
||||
|
||||
|
||||
@@ -411,6 +419,9 @@ class TestSlackThreadContext:
|
||||
adapter = _make_adapter()
|
||||
# Add a second workspace with a different bot user id
|
||||
adapter._team_clients["T2"] = AsyncMock()
|
||||
adapter._team_clients["T2"].users_info = AsyncMock(
|
||||
return_value={"user": {"name": "testuser", "real_name": "Test User"}}
|
||||
)
|
||||
adapter._team_bot_user_ids = {"T1": "U_BOT_T1", "T2": "U_BOT_T2"}
|
||||
adapter._bot_user_id = "U_BOT_T1"
|
||||
adapter._channel_team["C2"] = "T2"
|
||||
|
||||
Reference in New Issue
Block a user