SES: Fix GetSendStatistics response template (#4826)

This commit is contained in:
Viren Nadkarni 2022-02-08 22:54:41 +05:30 committed by GitHub
parent eba0fb8adc
commit 38bf0265c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -431,13 +431,13 @@ GET_SEND_STATISTICS = """<GetSendStatisticsResponse xmlns="http://ses.amazonaws.
<GetSendStatisticsResult>
<SendDataPoints>
{% for statistics in all_statistics %}
<item>
<member>
<DeliveryAttempts>{{ statistics["DeliveryAttempts"] }}</DeliveryAttempts>
<Rejects>{{ statistics["Rejects"] }}</Rejects>
<Bounces>{{ statistics["Bounces"] }}</Bounces>
<Complaints>{{ statistics["Complaints"] }}</Complaints>
<Timestamp>{{ statistics["Timestamp"] }}</Timestamp>
</item>
<Timestamp>{{ statistics["Timestamp"].isoformat() }}</Timestamp>
</member>
{% endfor %}
</SendDataPoints>
</GetSendStatisticsResult>

View File

@ -1,3 +1,6 @@
from datetime import datetime
import re
import sure # noqa # pylint: disable=unused-import
import moto.server as server
@ -13,3 +16,16 @@ def test_ses_list_identities():
res = test_client.get("/?Action=ListIdentities")
res.data.should.contain(b"ListIdentitiesResponse")
def test_ses_get_send_statistics():
backend = server.create_backend_app("ses")
test_client = backend.test_client()
res = test_client.get("/?Action=GetSendStatistics")
res.data.should.contain(b"GetSendStatisticsResponse")
# Timestamps must be in ISO 8601 format
groups = re.search("<Timestamp>(.*)</Timestamp>", res.data.decode("utf-8"))
timestamp = groups.groups()[0]
datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%f")