Skip to content

Commit 517a558

Browse files
committed
Reformat code with black
1 parent cd41c0d commit 517a558

File tree

3 files changed

+52
-10
lines changed

3 files changed

+52
-10
lines changed

packages/slackBotFunction/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ def process_async_slack_event(slack_event_data):
135135

136136
logger.info(
137137
f"Processing async @mention from user {user_id}",
138-
extra={"user_query": user_query, "thread_ts": thread_ts, "event_id": event_id},
138+
extra={
139+
"user_query": user_query,
140+
"thread_ts": thread_ts,
141+
"event_id": event_id,
142+
},
139143
)
140144

141145
if not user_query:

packages/slackBotFunction/query_reformulator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ def reformulate_query(user_query: str) -> str:
3030
reformulated_query = result["content"][0]["text"].strip()
3131

3232
logger.info(
33-
"Query reformulated", extra={"original_query": user_query, "reformulated_query": reformulated_query}
33+
"Query reformulated",
34+
extra={
35+
"original_query": user_query,
36+
"reformulated_query": reformulated_query,
37+
},
3438
)
3539

3640
return reformulated_query

packages/slackBotFunction/tests/test_app.py

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def test_is_duplicate_event(mock_time, mock_boto_resource, mock_get_parameter, m
8989
# Mock ConditionalCheckFailedException
9090
from botocore.exceptions import ClientError
9191

92-
error = ClientError(error_response={"Error": {"Code": "ConditionalCheckFailedException"}}, operation_name="PutItem")
92+
error = ClientError(
93+
error_response={"Error": {"Code": "ConditionalCheckFailedException"}},
94+
operation_name="PutItem",
95+
)
9396
mock_table.put_item.side_effect = error
9497

9598
if "app" in sys.modules:
@@ -362,7 +365,12 @@ def test_process_async_slack_event_success(mock_webclient, mock_boto_resource, m
362365
from app import process_async_slack_event
363366

364367
slack_event_data = {
365-
"event": {"text": "<@U123> test question", "user": "U456", "channel": "C789", "ts": "1234567890.123"},
368+
"event": {
369+
"text": "<@U123> test question",
370+
"user": "U456",
371+
"channel": "C789",
372+
"ts": "1234567890.123",
373+
},
366374
"event_id": "evt123",
367375
"bot_token": "bot-token",
368376
}
@@ -438,7 +446,12 @@ def test_process_async_slack_event_error(mock_webclient, mock_boto_resource, moc
438446
from app import process_async_slack_event
439447

440448
slack_event_data = {
441-
"event": {"text": "test question", "user": "U456", "channel": "C789", "ts": "1234567890.123"},
449+
"event": {
450+
"text": "test question",
451+
"user": "U456",
452+
"channel": "C789",
453+
"ts": "1234567890.123",
454+
},
442455
"event_id": "evt123",
443456
"bot_token": "bot-token",
444457
}
@@ -585,7 +598,12 @@ def test_log_request_middleware_execution_fixed(mock_boto_resource, mock_get_par
585598
@patch("boto3.client")
586599
@patch("time.time")
587600
def test_app_mention_handler_execution_simple(
588-
mock_time, mock_boto_client, mock_boto_resource, mock_get_parameter, mock_app_class, mock_env
601+
mock_time,
602+
mock_boto_client,
603+
mock_boto_resource,
604+
mock_get_parameter,
605+
mock_app_class,
606+
mock_env,
589607
):
590608
"""Test app mention handler execution by simulating the handler registration process"""
591609
mock_get_parameter.side_effect = [
@@ -643,7 +661,10 @@ def decorator(func):
643661
# Test 2: Duplicate event
644662
from botocore.exceptions import ClientError
645663

646-
error = ClientError(error_response={"Error": {"Code": "ConditionalCheckFailedException"}}, operation_name="PutItem")
664+
error = ClientError(
665+
error_response={"Error": {"Code": "ConditionalCheckFailedException"}},
666+
operation_name="PutItem",
667+
)
647668
mock_table.put_item.side_effect = error
648669

649670
handler_func(event, mock_ack, body)
@@ -668,7 +689,12 @@ def decorator(func):
668689
@patch("boto3.client")
669690
@patch("time.time")
670691
def test_direct_message_handler_execution_simple(
671-
mock_time, mock_boto_client, mock_boto_resource, mock_get_parameter, mock_app_class, mock_env
692+
mock_time,
693+
mock_boto_client,
694+
mock_boto_resource,
695+
mock_get_parameter,
696+
mock_app_class,
697+
mock_env,
672698
):
673699
"""Test direct message handler execution by simulating the handler registration process"""
674700
mock_get_parameter.side_effect = [
@@ -737,7 +763,10 @@ def decorator(func):
737763
# Test 3: IM channel with duplicate event
738764
from botocore.exceptions import ClientError
739765

740-
error = ClientError(error_response={"Error": {"Code": "ConditionalCheckFailedException"}}, operation_name="PutItem")
766+
error = ClientError(
767+
error_response={"Error": {"Code": "ConditionalCheckFailedException"}},
768+
operation_name="PutItem",
769+
)
741770
mock_table.put_item.side_effect = error
742771

743772
handler_func(event, mock_ack, body)
@@ -762,7 +791,12 @@ def decorator(func):
762791
@patch("boto3.client")
763792
@patch("time.time")
764793
def test_handlers_direct_call_coverage(
765-
mock_time, mock_boto_client, mock_boto_resource, mock_get_parameter, mock_app_class, mock_env
794+
mock_time,
795+
mock_boto_client,
796+
mock_boto_resource,
797+
mock_get_parameter,
798+
mock_app_class,
799+
mock_env,
766800
):
767801
"""Test handlers by calling them directly to ensure coverage"""
768802
mock_get_parameter.side_effect = [

0 commit comments

Comments
 (0)