From 80379312a34e2aa6f4a1fe808163a92fe265aa5d Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Thu, 23 Sep 2021 11:51:34 +0000 Subject: [PATCH] SES - duplicate boto tests (#4330) --- tests/test_ses/test_ses.py | 7 ++++++ tests/test_ses/test_ses_boto3.py | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/tests/test_ses/test_ses.py b/tests/test_ses/test_ses.py index ce0062974..776d6dc8f 100644 --- a/tests/test_ses/test_ses.py +++ b/tests/test_ses/test_ses.py @@ -9,6 +9,7 @@ import sure # noqa from moto import mock_ses_deprecated +# Has boto3 equivalent @mock_ses_deprecated def test_verify_email_identity(): conn = boto.connect_ses("the_key", "the_secret") @@ -21,6 +22,7 @@ def test_verify_email_identity(): address.should.equal("test@example.com") +# Has boto3 equivalent @mock_ses_deprecated def test_domain_verify(): conn = boto.connect_ses("the_key", "the_secret") @@ -35,6 +37,7 @@ def test_domain_verify(): domains.should.equal(["domain1.com", "domain2.com"]) +# Has boto3 equivalent @mock_ses_deprecated def test_delete_identity(): conn = boto.connect_ses("the_key", "the_secret") @@ -49,6 +52,7 @@ def test_delete_identity(): ].should.have.length_of(0) +# Has boto3 equivalent @mock_ses_deprecated def test_send_email(): conn = boto.connect_ses("the_key", "the_secret") @@ -69,6 +73,7 @@ def test_send_email(): sent_count.should.equal(1) +# Has boto3 equivalent @mock_ses_deprecated def test_send_html_email(): conn = boto.connect_ses("the_key", "the_secret") @@ -97,6 +102,7 @@ def test_send_html_email(): sent_count.should.equal(1) +# Has boto3 equivalent @mock_ses_deprecated def test_send_raw_email(): conn = boto.connect_ses("the_key", "the_secret") @@ -129,6 +135,7 @@ def test_send_raw_email(): sent_count.should.equal(1) +# Has boto3 equivalent @mock_ses_deprecated def test_get_send_statistics(): conn = boto.connect_ses("the_key", "the_secret") diff --git a/tests/test_ses/test_ses_boto3.py b/tests/test_ses/test_ses_boto3.py index ae0c5f7c5..fcf218cb7 100644 --- a/tests/test_ses/test_ses_boto3.py +++ b/tests/test_ses/test_ses_boto3.py @@ -614,3 +614,44 @@ def test_domains_are_case_insensitive(): identities = client.list_identities(IdentityType="Domain")["Identities"] identities.should.have.length_of(1) identities[0].should.equal("example.com") + + +@mock_ses +def test_get_send_statistics(): + conn = boto3.client("ses", region_name="us-east-1") + + kwargs = dict( + Source="test@example.com", + Destination={"ToAddresses": ["test_to@example.com"],}, + Message={ + "Subject": {"Data": "test subject"}, + "Body": {"Html": {"Data": "test body"}}, + }, + ) + with pytest.raises(ClientError) as ex: + conn.send_email(**kwargs) + err = ex.value.response["Error"] + err["Code"].should.equal("MessageRejected") + err["Message"].should.equal("Email address not verified test@example.com") + + # tests to verify rejects in get_send_statistics + stats = conn.get_send_statistics()["SendDataPoints"] + + stats[0]["Rejects"].should.equal(1) + stats[0]["DeliveryAttempts"].should.equal(0) + + conn.verify_email_identity(EmailAddress="test@example.com") + conn.send_email( + Source="test@example.com", + Message={ + "Subject": {"Data": "test subject"}, + "Body": {"Text": {"Data": "test body"}}, + }, + Destination={"ToAddresses": ["test_to@example.com"],}, + ) + + # tests to delivery attempts in get_send_statistics + stats = conn.get_send_statistics()["SendDataPoints"] + + stats[0]["Rejects"].should.equal(1) + stats[0]["DeliveryAttempts"].should.equal(1)