File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
- from aws_lambda_powertools .utilities .parser import event_parser
1
+ import pytest
2
+
3
+ from aws_lambda_powertools .utilities .parser import ValidationError , event_parser
2
4
from aws_lambda_powertools .utilities .parser .models import SqsS3EventNotificationModel
3
5
from aws_lambda_powertools .utilities .typing import LambdaContext
4
6
from tests .functional .utils import json_serialize , load_event
@@ -20,3 +22,19 @@ def test_handle_sqs_json_body_containing_s3_notifications():
20
22
assert len (parsed_event .Records ) == 2
21
23
for parsed_sqs_record in parsed_event .Records :
22
24
assert_s3 (parsed_sqs_record .body )
25
+
26
+
27
+ def test_handle_sqs_body_invalid_json ():
28
+ sqs_event_dict = load_event ("sqsEvent.json" )
29
+
30
+ with pytest .raises (ValidationError ):
31
+ handle_sqs_json_body_containing_s3_notifications (sqs_event_dict , LambdaContext ())
32
+
33
+
34
+ def test_handle_sqs_json_body_containing_arbitrary_json ():
35
+ sqs_event_dict = load_event ("sqsEvent.json" )
36
+ for record in sqs_event_dict ["Records" ]:
37
+ record ["body" ] = json_serialize ({"foo" : "bar" })
38
+
39
+ with pytest .raises (ValidationError ):
40
+ handle_sqs_json_body_containing_s3_notifications (sqs_event_dict , LambdaContext ())
You can’t perform that action at this time.
0 commit comments