Skip to content

Commit 4de8cae

Browse files
committed
Merge branch 'pull_request_conversation_1' into pull_request_conversation_2
2 parents 64cfaf1 + d2b845a commit 4de8cae

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/slackBotFunction/app/slack/slack_events.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from app.core.config import (
1414
bot_messages,
1515
constants,
16+
get_bot_token,
1617
get_logger,
1718
)
1819
from app.services.bedrock import query_bedrock
@@ -252,12 +253,14 @@ def process_pull_request_slack_event(slack_event_data: Dict[str, Any]) -> None:
252253
try:
253254
event_id = slack_event_data["event_id"]
254255
event = slack_event_data["event"]
256+
token = get_bot_token()
257+
client = WebClient(token=token)
255258
if is_duplicate_event(event_id=event_id):
256259
return
257260
message_text = event["text"]
258261
_, extracted_message = extract_pull_request_id(message_text)
259262
event["text"] = extracted_message
260-
process_async_slack_event(event=event, event_id=event_id)
263+
process_async_slack_event(event=event, event_id=event_id, client=client)
261264
except Exception:
262265
# we cant post a reply to slack for this error as we may not have details about where to post it
263266
logger.error("Error processing message", extra={"event_id": event_id, "error": traceback.format_exc()})

packages/slackBotFunction/tests/test_pulll_request_processing.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import sys
2-
from unittest.mock import Mock, patch
2+
from unittest.mock import ANY, Mock, patch
33

44

55
@patch("app.utils.handler_utils.is_duplicate_event")
66
@patch("app.utils.handler_utils.extract_pull_request_id")
7-
def test_process_pull_request_event(mock_extract_pull_request_id: Mock, mock_is_duplicate_event: Mock, mock_env: Mock):
7+
def test_process_pull_request_event(
8+
mock_extract_pull_request_id: Mock, mock_is_duplicate_event: Mock, mock_env: Mock, mock_get_parameter: Mock
9+
):
810
# set up mocks
911
mock_is_duplicate_event.return_value = False
1012
mock_extract_pull_request_id.return_value = None, "test question"
@@ -37,7 +39,9 @@ def test_process_pull_request_event(mock_extract_pull_request_id: Mock, mock_is_
3739
"ts": "1234567890.123",
3840
"thread_ts": "1234567888.111", # Existing thread
3941
}
40-
mock_process_async_slack_event.assert_called_once_with(event=expected_slack_event_data, event_id="evt123")
42+
mock_process_async_slack_event.assert_called_once_with(
43+
event=expected_slack_event_data, event_id="evt123", client=ANY
44+
)
4145

4246

4347
@patch("app.utils.handler_utils.is_duplicate_event")

0 commit comments

Comments
 (0)