Fix:SES-Added params check in template (#3753)

* Fix:SES-Added params check in template

* Added more tests and handled message

* linting

* fixed tests

* fix attribute name in message

* fix logic for exception
This commit is contained in:
usmangani1 2021-05-18 12:21:27 +05:30 committed by GitHub
commit 31cf3c4252
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 1 deletions

View file

@ -8,7 +8,7 @@ from six.moves.email_mime_text import MIMEText
import pytest
import sure # noqa
# import sure # noqa
from moto import mock_ses
@ -531,6 +531,40 @@ def test_render_template():
result["RenderedTemplate"].should.contain("<h1>Hello John,</h1>")
result["RenderedTemplate"].should.contain("Your favorite animal is Lion")
kwargs = dict(
TemplateName="MyTestTemplate",
TemplateData=json.dumps({"name": "John", "favoriteanimal": "Lion"}),
)
conn.create_template(
Template={
"TemplateName": "MyTestTemplate1",
"SubjectPart": "Greetings, {{name}}!",
"TextPart": "Dear {{name}},"
"\r\nYour favorite animal is {{favoriteanimal}}.",
"HtmlPart": "<h1>Hello {{name}},"
"</h1><p>Your favorite animal is {{favoriteanimal }}.</p>",
}
)
result = conn.test_render_template(**kwargs)
result["RenderedTemplate"].should.contain("Subject: Greetings, John!")
result["RenderedTemplate"].should.contain("Dear John,")
result["RenderedTemplate"].should.contain("<h1>Hello John,</h1>")
result["RenderedTemplate"].should.contain("Your favorite animal is Lion")
kwargs = dict(
TemplateName="MyTestTemplate", TemplateData=json.dumps({"name": "John"}),
)
with pytest.raises(ClientError) as ex:
conn.test_render_template(**kwargs)
assert ex.value.response["Error"]["Code"] == "MissingRenderingAttributeException"
assert (
ex.value.response["Error"]["Message"]
== "Attribute 'favoriteanimal' is not present in the rendering data."
)
@mock_ses
def test_update_ses_template():