Run black on moto & test directories.
This commit is contained in:
parent
c820395dbf
commit
96e5b1993d
507 changed files with 52541 additions and 47814 deletions
|
|
@ -14,19 +14,16 @@ from moto.ses.models import SESFeedback
|
|||
|
||||
@mock_ses
|
||||
def test_enable_disable_ses_sns_communication():
|
||||
conn = boto3.client('ses', region_name='us-east-1')
|
||||
conn = boto3.client("ses", region_name="us-east-1")
|
||||
conn.set_identity_notification_topic(
|
||||
Identity='test.com',
|
||||
NotificationType='Bounce',
|
||||
SnsTopic='the-arn'
|
||||
)
|
||||
conn.set_identity_notification_topic(
|
||||
Identity='test.com',
|
||||
NotificationType='Bounce'
|
||||
Identity="test.com", NotificationType="Bounce", SnsTopic="the-arn"
|
||||
)
|
||||
conn.set_identity_notification_topic(Identity="test.com", NotificationType="Bounce")
|
||||
|
||||
|
||||
def __setup_feedback_env__(ses_conn, sns_conn, sqs_conn, domain, topic, queue, region, expected_msg):
|
||||
def __setup_feedback_env__(
|
||||
ses_conn, sns_conn, sqs_conn, domain, topic, queue, region, expected_msg
|
||||
):
|
||||
"""Setup the AWS environment to test the SES SNS Feedback"""
|
||||
# Environment setup
|
||||
# Create SQS queue
|
||||
|
|
@ -35,30 +32,32 @@ def __setup_feedback_env__(ses_conn, sns_conn, sqs_conn, domain, topic, queue, r
|
|||
create_topic_response = sns_conn.create_topic(Name=topic)
|
||||
topic_arn = create_topic_response["TopicArn"]
|
||||
# Subscribe the SNS topic to the SQS queue
|
||||
sns_conn.subscribe(TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:%s:123456789012:%s" % (region, queue))
|
||||
sns_conn.subscribe(
|
||||
TopicArn=topic_arn,
|
||||
Protocol="sqs",
|
||||
Endpoint="arn:aws:sqs:%s:123456789012:%s" % (region, queue),
|
||||
)
|
||||
# Verify SES domain
|
||||
ses_conn.verify_domain_identity(Domain=domain)
|
||||
# Setup SES notification topic
|
||||
if expected_msg is not None:
|
||||
ses_conn.set_identity_notification_topic(
|
||||
Identity=domain,
|
||||
NotificationType=expected_msg,
|
||||
SnsTopic=topic_arn
|
||||
Identity=domain, NotificationType=expected_msg, SnsTopic=topic_arn
|
||||
)
|
||||
|
||||
|
||||
def __test_sns_feedback__(addr, expected_msg):
|
||||
region_name = "us-east-1"
|
||||
ses_conn = boto3.client('ses', region_name=region_name)
|
||||
sns_conn = boto3.client('sns', region_name=region_name)
|
||||
sqs_conn = boto3.resource('sqs', region_name=region_name)
|
||||
ses_conn = boto3.client("ses", region_name=region_name)
|
||||
sns_conn = boto3.client("sns", region_name=region_name)
|
||||
sqs_conn = boto3.resource("sqs", region_name=region_name)
|
||||
domain = "example.com"
|
||||
topic = "bounce-arn-feedback"
|
||||
queue = "feedback-test-queue"
|
||||
|
||||
__setup_feedback_env__(ses_conn, sns_conn, sqs_conn, domain, topic, queue, region_name, expected_msg)
|
||||
__setup_feedback_env__(
|
||||
ses_conn, sns_conn, sqs_conn, domain, topic, queue, region_name, expected_msg
|
||||
)
|
||||
|
||||
# Send the message
|
||||
kwargs = dict(
|
||||
|
|
@ -70,8 +69,8 @@ def __test_sns_feedback__(addr, expected_msg):
|
|||
},
|
||||
Message={
|
||||
"Subject": {"Data": "test subject"},
|
||||
"Body": {"Text": {"Data": "test body"}}
|
||||
}
|
||||
"Body": {"Text": {"Data": "test body"}},
|
||||
},
|
||||
)
|
||||
ses_conn.send_email(**kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue