Skip to content

Commit b92b15e

Browse files
committed
test: functional tests for partial sqs processor and its middleware
1 parent 2deda80 commit b92b15e

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

tests/functional/test_utilities_batch.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Callable
2-
import pytest
32

3+
import pytest
44
from botocore.stub import Stubber
55

66
from aws_lambda_powertools.utilities.batch import PartialSQSProcessor, partial_sqs_processor
@@ -36,15 +36,17 @@ def handler(record):
3636

3737

3838
def test_partial_sqs_processor_context_with_failure(sqs_event_factory, record_handler):
39-
""" Test processor with one record failing """
39+
"""
40+
Test processor with one failing record
41+
"""
4042
processor = PartialSQSProcessor()
4143

4244
fail_record = sqs_event_factory("fail")
4345
success_record = sqs_event_factory("success")
4446

4547
records = [fail_record, success_record]
4648

47-
response = {"Successful": [{"Id": fail_record["messageId"]},], "Failed": []}
49+
response = {"Successful": [{"Id": fail_record["messageId"]}], "Failed": []}
4850

4951
with Stubber(processor.client) as stubber:
5052
stubber.add_response("delete_message_batch", response)
@@ -61,7 +63,10 @@ def test_partial_sqs_processor_context_with_failure(sqs_event_factory, record_ha
6163

6264

6365
def test_partial_sqs_processor_context_only_success(sqs_event_factory, record_handler):
64-
""" Test processor without failure """
66+
"""
67+
Test processor without failure
68+
"""
69+
6570
processor = PartialSQSProcessor()
6671

6772
first_record = sqs_event_factory("success")
@@ -79,7 +84,10 @@ def test_partial_sqs_processor_context_only_success(sqs_event_factory, record_ha
7984

8085

8186
def test_partial_sqs_processor_context_multiple_calls(sqs_event_factory, record_handler):
82-
""" Test processor without failure """
87+
"""
88+
Test processor without failure
89+
"""
90+
8391
processor = PartialSQSProcessor()
8492

8593
first_record = sqs_event_factory("success")
@@ -97,7 +105,10 @@ def test_partial_sqs_processor_context_multiple_calls(sqs_event_factory, record_
97105

98106

99107
def test_partial_sqs_processor_middleware_with_default(sqs_event_factory, record_handler):
100-
""" Test middleware with default partial processor """
108+
"""
109+
Test middleware with default partial processor
110+
"""
111+
101112
processor = PartialSQSProcessor()
102113

103114
@partial_sqs_processor(record_handler=record_handler, processor=processor)
@@ -107,7 +118,7 @@ def lambda_handler(event, context):
107118
fail_record = sqs_event_factory("fail")
108119

109120
event = {"Records": [sqs_event_factory("fail"), sqs_event_factory("success")]}
110-
response = {"Successful": [{"Id": fail_record["messageId"]},], "Failed": []}
121+
response = {"Successful": [{"Id": fail_record["messageId"]}], "Failed": []}
111122

112123
with Stubber(processor.client) as stubber:
113124
stubber.add_response("delete_message_batch", response)
@@ -120,7 +131,10 @@ def lambda_handler(event, context):
120131

121132

122133
def test_partial_sqs_processor_middleware_with_custom(capsys, sqs_event_factory, record_handler):
123-
""" Test middle with custom partial processor """
134+
"""
135+
Test middle with custom partial processor
136+
"""
137+
124138
class CustomProcessor(PartialSQSProcessor):
125139
def failure_handler(self, record, exception):
126140
print("Oh no ! It's a failure.")
@@ -135,7 +149,7 @@ def lambda_handler(event, context):
135149
fail_record = sqs_event_factory("fail")
136150

137151
event = {"Records": [sqs_event_factory("fail"), sqs_event_factory("success")]}
138-
response = {"Successful": [{"Id": fail_record["messageId"]},], "Failed": []}
152+
response = {"Successful": [{"Id": fail_record["messageId"]}], "Failed": []}
139153

140154
with Stubber(processor.client) as stubber:
141155
stubber.add_response("delete_message_batch", response)

0 commit comments

Comments
 (0)