1
1
from aws_lambda_powertools .utilities .parser import event_parser
2
- from aws_lambda_powertools .utilities .parser .models import (
3
- SesModel ,
4
- SesReceiptBounceAction ,
5
- SesReceiptWorkmailAction ,
6
- SesRecordModel ,
7
- )
2
+ from aws_lambda_powertools .utilities .parser .models import SesModel , SesRecordModel
8
3
from aws_lambda_powertools .utilities .typing import LambdaContext
9
4
from tests .functional .utils import load_event
10
5
11
6
12
7
@event_parser (model = SesModel )
13
- def handle_ses (event : SesModel , _ : LambdaContext ) -> SesModel :
14
- return event
15
-
16
-
17
- def test_ses_trigger_lambda_event ():
18
- event_dict = load_event ("sesEvent.json" )
19
- event = handle_ses (event_dict , LambdaContext ())
8
+ def handle_ses (event : SesModel , _ : LambdaContext ):
20
9
expected_address = "[email protected] "
21
10
records = event .Records
22
11
record : SesRecordModel = records [0 ]
@@ -40,10 +29,6 @@ def test_ses_trigger_lambda_event():
40
29
assert common_headers .to == [expected_address ]
41
30
assert common_headers .messageId == "<0123456789example.com>"
42
31
assert common_headers .subject == "Test Subject"
43
- assert common_headers .cc is None
44
- assert common_headers .bcc is None
45
- assert common_headers .sender is None
46
- assert common_headers .reply_to is None
47
32
receipt = record .ses .receipt
48
33
convert_time = int (round (receipt .timestamp .timestamp () * 1000 ))
49
34
assert convert_time == 0
@@ -53,45 +38,12 @@ def test_ses_trigger_lambda_event():
53
38
assert receipt .virusVerdict .status == "PASS"
54
39
assert receipt .spfVerdict .status == "PASS"
55
40
assert receipt .dmarcVerdict .status == "PASS"
56
- assert receipt .dmarcVerdict .status == "PASS"
57
- assert receipt .dmarcPolicy is None
58
41
action = receipt .action
59
42
assert action .type == "Lambda"
60
43
assert action .functionArn == "arn:aws:lambda:us-west-2:012345678912:function:Example"
61
44
assert action .invocationType == "Event"
62
- assert action .topicArn is None
63
-
64
45
65
- def test_ses_trigger_event_s3 ():
66
- event_dict = load_event ("sesEventS3.json" )
67
- event = handle_ses (event_dict , LambdaContext ())
68
- records = list (event .Records )
69
- record = records [0 ]
70
- receipt = record .ses .receipt
71
- assert receipt .dmarcPolicy == "reject"
72
- action = record .ses .receipt .action
73
- assert action .type == "S3"
74
- assert action .topicArn == "arn:aws:sns:us-east-1:012345678912:example-topic"
75
- assert action .bucketName == "my-S3-bucket"
76
- assert action .objectKey == "email"
77
-
78
-
79
- def test_ses_trigger_event_bounce ():
80
- event_dict = {
81
- "type" : "Bounce" ,
82
- "topicArn" : "arn:aws:sns:us-east-1:123456789012:topic:my-topic" ,
83
- "smtpReplyCode" : "5.1.1" ,
84
- "message" : "message" ,
85
- "sender" : "sender" ,
86
- "statusCode" : "550" ,
87
- }
88
- SesReceiptBounceAction (** event_dict )
89
46
90
-
91
- def test_ses_trigger_event_work_mail ():
92
- event_dict = {
93
- "type" : "WorkMail" ,
94
- "topicArn" : "arn:aws:sns:us-east-1:123456789012:topic:my-topic" ,
95
- "organizationArn" : "arn" ,
96
- }
97
- SesReceiptWorkmailAction (** event_dict )
47
+ def test_ses_trigger_event ():
48
+ event_dict = load_event ("sesEvent.json" )
49
+ handle_ses (event_dict , LambdaContext ())
0 commit comments