Skip to content

Commit 7f608bd

Browse files
committed
Reformat code with black
1 parent 769af6f commit 7f608bd

File tree

3 files changed

+67
-14
lines changed

3 files changed

+67
-14
lines changed

packages/slackBotFunction/app.py

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

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

140144
if not user_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 = [

packages/syncKnowledgeBaseFunction/tests/test_app.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def s3_event():
3333
{
3434
"eventSource": "aws:s3",
3535
"eventName": "ObjectCreated:Put",
36-
"s3": {"bucket": {"name": "test-bucket"}, "object": {"key": "test-file.pdf", "size": 1024}},
36+
"s3": {
37+
"bucket": {"name": "test-bucket"},
38+
"object": {"key": "test-file.pdf", "size": 1024},
39+
},
3740
}
3841
]
3942
}
@@ -157,12 +160,18 @@ def test_handler_multiple_records(mock_time, mock_bedrock, mock_env, lambda_cont
157160
{
158161
"eventSource": "aws:s3",
159162
"eventName": "ObjectCreated:Put",
160-
"s3": {"bucket": {"name": "test-bucket"}, "object": {"key": "file1.pdf", "size": 1024}},
163+
"s3": {
164+
"bucket": {"name": "test-bucket"},
165+
"object": {"key": "file1.pdf", "size": 1024},
166+
},
161167
},
162168
{
163169
"eventSource": "aws:s3",
164170
"eventName": "ObjectRemoved:Delete",
165-
"s3": {"bucket": {"name": "test-bucket"}, "object": {"key": "file2.pdf", "size": 2048}},
171+
"s3": {
172+
"bucket": {"name": "test-bucket"},
173+
"object": {"key": "file2.pdf", "size": 2048},
174+
},
166175
},
167176
]
168177
}
@@ -206,7 +215,10 @@ def test_handler_missing_object_size(mock_bedrock, mock_env, lambda_context):
206215
{
207216
"eventSource": "aws:s3",
208217
"eventName": "ObjectCreated:Put",
209-
"s3": {"bucket": {"name": "test-bucket"}, "object": {"key": "test-file.pdf"}},
218+
"s3": {
219+
"bucket": {"name": "test-bucket"},
220+
"object": {"key": "test-file.pdf"},
221+
},
210222
}
211223
]
212224
}
@@ -234,7 +246,10 @@ def test_handler_partial_env_vars(mock_bedrock, lambda_context, s3_event):
234246
@patch("app.bedrock_agent")
235247
def test_handler_client_error_no_message(mock_bedrock, mock_env, lambda_context, s3_event):
236248
"""Test handler with ClientError missing message"""
237-
error = ClientError(error_response={"Error": {"Code": "TestError"}}, operation_name="StartIngestionJob")
249+
error = ClientError(
250+
error_response={"Error": {"Code": "TestError"}},
251+
operation_name="StartIngestionJob",
252+
)
238253
mock_bedrock.start_ingestion_job.side_effect = error
239254

240255
result = app.handler(s3_event, lambda_context)

0 commit comments

Comments
 (0)