Enhancement Adding SES get_send_statistics,create_configuration_set functions

This commit is contained in:
usmankb 2020-05-01 21:16:33 +05:30
commit 440213f854
5 changed files with 202 additions and 1 deletions

View file

@ -127,3 +127,39 @@ def test_send_raw_email():
send_quota["GetSendQuotaResponse"]["GetSendQuotaResult"]["SentLast24Hours"]
)
sent_count.should.equal(1)
@mock_ses_deprecated
def test_get_send_statistics():
conn = boto.connect_ses("the_key", "the_secret")
conn.send_email.when.called_with(
"test@example.com",
"test subject",
"<span>test body</span>",
"test_to@example.com",
format="html",
).should.throw(BotoServerError)
# tests to verify rejects in get_send_statistics
result = conn.get_send_statistics()
reject_count = int(result["GetSendStatisticsResponse"]["SendDataPoints"][0]["Rejects"])
delivery_count = int(result["GetSendStatisticsResponse"]["SendDataPoints"][0]["DeliveryAttempts"])
reject_count.should.equal(1)
delivery_count.should.equal(0)
conn.verify_email_identity("test@example.com")
conn.send_email(
"test@example.com", "test subject", "test body", "test_to@example.com"
)
# tests to delivery attempts in get_send_statistics
result = conn.get_send_statistics()
reject_count = int(result["GetSendStatisticsResponse"]["SendDataPoints"][0]["Rejects"])
delivery_count = int(result["GetSendStatisticsResponse"]["SendDataPoints"][0]["DeliveryAttempts"])
reject_count.should.equal(1)
delivery_count.should.equal(1)

View file

@ -4,6 +4,8 @@ import boto3
from botocore.exceptions import ClientError
from six.moves.email_mime_multipart import MIMEMultipart
from six.moves.email_mime_text import MIMEText
from nose.tools import assert_raises
import sure # noqa
@ -227,3 +229,53 @@ def test_send_email_notification_with_encoded_sender():
Message={"Subject": {"Data": "hi",}, "Body": {"Text": {"Data": "there",}}},
)
response["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
@mock_ses
def test_create_configuration_set():
conn = boto3.client("ses", region_name="us-east-1")
conn.create_configuration_set(ConfigurationSet=dict({"Name": "test"}))
conn.create_configuration_set_event_destination(
ConfigurationSetName='test',
EventDestination={
'Name': 'snsEvent',
'Enabled': True,
'MatchingEventTypes': [
'send',
],
'SNSDestination': {
'TopicARN': 'arn:aws:sns:us-east-1:123456789012:myTopic'
}
})
with assert_raises(ClientError) as ex:
conn.create_configuration_set_event_destination(
ConfigurationSetName='failtest',
EventDestination={
'Name': 'snsEvent',
'Enabled': True,
'MatchingEventTypes': [
'send',
],
'SNSDestination': {
'TopicARN': 'arn:aws:sns:us-east-1:123456789012:myTopic'
}
})
ex.exception.response["Error"]["Code"].should.equal("ConfigurationSetDoesNotExist")
with assert_raises(ClientError) as ex:
conn.create_configuration_set_event_destination(
ConfigurationSetName='test',
EventDestination={
'Name': 'snsEvent',
'Enabled': True,
'MatchingEventTypes': [
'send',
],
'SNSDestination': {
'TopicARN': 'arn:aws:sns:us-east-1:123456789012:myTopic'
}
})
ex.exception.response["Error"]["Code"].should.equal("EventDestinationAlreadyExists")