-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 797a10a.
- Loading branch information
1 parent
797a10a
commit 2656d6b
Showing
4 changed files
with
8 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
from aws_lambda_powertools.utilities.parser import event_parser | ||
from aws_lambda_powertools.utilities.parser.models import ( | ||
SesModel, | ||
SesReceiptBounceAction, | ||
SesReceiptWorkmailAction, | ||
SesRecordModel, | ||
) | ||
from aws_lambda_powertools.utilities.parser.models import SesModel, SesRecordModel | ||
from aws_lambda_powertools.utilities.typing import LambdaContext | ||
from tests.functional.utils import load_event | ||
|
||
|
||
@event_parser(model=SesModel) | ||
def handle_ses(event: SesModel, _: LambdaContext) -> SesModel: | ||
return event | ||
|
||
|
||
def test_ses_trigger_lambda_event(): | ||
event_dict = load_event("sesEvent.json") | ||
event = handle_ses(event_dict, LambdaContext()) | ||
def handle_ses(event: SesModel, _: LambdaContext): | ||
expected_address = "[email protected]" | ||
records = event.Records | ||
record: SesRecordModel = records[0] | ||
|
@@ -40,10 +29,6 @@ def test_ses_trigger_lambda_event(): | |
assert common_headers.to == [expected_address] | ||
assert common_headers.messageId == "<0123456789example.com>" | ||
assert common_headers.subject == "Test Subject" | ||
assert common_headers.cc is None | ||
assert common_headers.bcc is None | ||
assert common_headers.sender is None | ||
assert common_headers.reply_to is None | ||
receipt = record.ses.receipt | ||
convert_time = int(round(receipt.timestamp.timestamp() * 1000)) | ||
assert convert_time == 0 | ||
|
@@ -53,45 +38,12 @@ def test_ses_trigger_lambda_event(): | |
assert receipt.virusVerdict.status == "PASS" | ||
assert receipt.spfVerdict.status == "PASS" | ||
assert receipt.dmarcVerdict.status == "PASS" | ||
assert receipt.dmarcVerdict.status == "PASS" | ||
assert receipt.dmarcPolicy is None | ||
action = receipt.action | ||
assert action.type == "Lambda" | ||
assert action.functionArn == "arn:aws:lambda:us-west-2:012345678912:function:Example" | ||
assert action.invocationType == "Event" | ||
assert action.topicArn is None | ||
|
||
|
||
def test_ses_trigger_event_s3(): | ||
event_dict = load_event("sesEventS3.json") | ||
event = handle_ses(event_dict, LambdaContext()) | ||
records = list(event.Records) | ||
record = records[0] | ||
receipt = record.ses.receipt | ||
assert receipt.dmarcPolicy == "reject" | ||
action = record.ses.receipt.action | ||
assert action.type == "S3" | ||
assert action.topicArn == "arn:aws:sns:us-east-1:012345678912:example-topic" | ||
assert action.bucketName == "my-S3-bucket" | ||
assert action.objectKey == "email" | ||
|
||
|
||
def test_ses_trigger_event_bounce(): | ||
event_dict = { | ||
"type": "Bounce", | ||
"topicArn": "arn:aws:sns:us-east-1:123456789012:topic:my-topic", | ||
"smtpReplyCode": "5.1.1", | ||
"message": "message", | ||
"sender": "sender", | ||
"statusCode": "550", | ||
} | ||
SesReceiptBounceAction(**event_dict) | ||
|
||
|
||
def test_ses_trigger_event_work_mail(): | ||
event_dict = { | ||
"type": "WorkMail", | ||
"topicArn": "arn:aws:sns:us-east-1:123456789012:topic:my-topic", | ||
"organizationArn": "arn", | ||
} | ||
SesReceiptWorkmailAction(**event_dict) | ||
def test_ses_trigger_event(): | ||
event_dict = load_event("sesEvent.json") | ||
handle_ses(event_dict, LambdaContext()) |