2525SAM_TEMPLATE_FILE = "sam.template.yaml"
2626SAM_SHUTDOWN_TIMEOUT = 10
2727
28+ SQS_RECORD = {
29+ "messageId" : "059f36b4-87a3-44ab-83d2-661975830a7d" ,
30+ "body" : "{}" ,
31+ "eventSource" : "aws:sqs" ,
32+ "eventSourceARN" : "arn:aws:sqs:us-east-1:012345678912:orders" ,
33+ }
34+ SNS_RECORD = {
35+ "EventSource" : "aws:sns" ,
36+ "Sns" : {"TopicArn" : "arn:aws:sns:us-east-1:012345678912:alerts" },
37+ }
38+ APPSYNC_EVENT = {
39+ "arguments" : {"id" : "1" },
40+ "info" : {"fieldName" : "getOrder" , "parentTypeName" : "Query" },
41+ }
42+ EVENTBRIDGE_EVENT = {
43+ "version" : "0" ,
44+ "id" : "53dc4d37-cffa-4f76-80c9-8b7d4a4d2eaa" ,
45+ "detail-type" : "Object Created" ,
46+ "source" : "aws.s3" ,
47+ "account" : "012345678912" ,
48+ "time" : "2026-10-26T12:00:00Z" ,
49+ "region" : "us-east-1" ,
50+ "resources" : [],
51+ "detail" : {},
52+ }
53+
2854
2955@pytest .fixture (scope = "session" , autouse = True )
3056def test_environment ():
@@ -824,43 +850,6 @@ def test_error(lambda_client, test_environment):
824850 assert _get_span_attr (attrs , SPANDATA .FAAS_TRIGGER ) == "other"
825851
826852
827- def _sqs_record ():
828- return {
829- "messageId" : "059f36b4-87a3-44ab-83d2-661975830a7d" ,
830- "body" : "{}" ,
831- "eventSource" : "aws:sqs" ,
832- "eventSourceARN" : "arn:aws:sqs:us-east-1:012345678912:orders" ,
833- }
834-
835-
836- def _sns_record ():
837- return {
838- "EventSource" : "aws:sns" ,
839- "Sns" : {"TopicArn" : "arn:aws:sns:us-east-1:012345678912:alerts" },
840- }
841-
842-
843- def _appsync_event ():
844- return {
845- "arguments" : {"id" : "1" },
846- "info" : {"fieldName" : "getOrder" , "parentTypeName" : "Query" },
847- }
848-
849-
850- def _eventbridge_event (source , detail_type ):
851- return {
852- "version" : "0" ,
853- "id" : "53dc4d37-cffa-4f76-80c9-8b7d4a4d2eaa" ,
854- "detail-type" : detail_type ,
855- "source" : source ,
856- "account" : "012345678912" ,
857- "time" : "2026-10-26T12:00:00Z" ,
858- "region" : "us-east-1" ,
859- "resources" : [],
860- "detail" : {},
861- }
862-
863-
864853@pytest .mark .parametrize (
865854 "aws_event,trigger" ,
866855 [
@@ -883,22 +872,26 @@ def _eventbridge_event(source, detail_type):
883872 "http" ,
884873 id = "cloudfront" ,
885874 ),
886- pytest .param (_appsync_event () , "http" , id = "appsync" ),
887- pytest .param ([_appsync_event (), _appsync_event () ], "http" , id = "appsync-batch" ),
888- pytest .param ({"Records" : [_sqs_record (), _sqs_record () ]}, "pubsub" , id = "sqs" ),
889- pytest .param ({"Records" : [_sns_record () ]}, "pubsub" , id = "sns" ),
875+ pytest .param (APPSYNC_EVENT , "http" , id = "appsync" ),
876+ pytest .param ([APPSYNC_EVENT , APPSYNC_EVENT ], "http" , id = "appsync-batch" ),
877+ pytest .param ({"Records" : [SQS_RECORD , SQS_RECORD ]}, "pubsub" , id = "sqs" ),
878+ pytest .param ({"Records" : [SNS_RECORD ]}, "pubsub" , id = "sns" ),
890879 pytest .param (
891880 {"eventSource" : "aws:kafka" , "records" : {"orders-0" : [{}]}},
892881 "pubsub" ,
893882 id = "msk" ,
894883 ),
895884 pytest .param (
896- _eventbridge_event ( "aws.s3" , "Object Created" ) ,
885+ EVENTBRIDGE_EVENT ,
897886 "pubsub" ,
898887 id = "eventbridge" ,
899888 ),
900889 pytest .param (
901- _eventbridge_event ("aws.events" , "Scheduled Event" ),
890+ {
891+ ** EVENTBRIDGE_EVENT ,
892+ "source" : "aws.events" ,
893+ "detail-type" : "Scheduled Event" ,
894+ },
902895 "timer" ,
903896 id = "eventbridge-schedule" ,
904897 ),
0 commit comments