Raise TemplateDoesNotExist
if template does not exist (#3784)
* Raise TemplateDoesNotExist if template does not exist When sending templated emails * Remove unnecessary 'when called with' in test
This commit is contained in:
parent
74272ae51c
commit
a5fc99c9af
@ -164,6 +164,9 @@ class SESBackend(BaseBackend):
|
||||
self.rejected_messages_count += 1
|
||||
raise MessageRejectedError("Email address not verified %s" % source)
|
||||
|
||||
if not self.templates.get(template[0]):
|
||||
raise TemplateDoesNotExist("Template (%s) does not exist" % template[0])
|
||||
|
||||
self.__process_sns_feedback__(source, destinations, region)
|
||||
|
||||
message_id = get_random_message_id()
|
||||
|
@ -132,6 +132,21 @@ def test_send_templated_email():
|
||||
conn.send_templated_email.when.called_with(**kwargs).should.throw(ClientError)
|
||||
|
||||
conn.verify_domain_identity(Domain="example.com")
|
||||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.send_templated_email(**kwargs)
|
||||
|
||||
ex.value.response["Error"]["Code"].should.equal("TemplateDoesNotExist")
|
||||
|
||||
conn.create_template(
|
||||
Template={
|
||||
"TemplateName": "test_template",
|
||||
"SubjectPart": "lalala",
|
||||
"HtmlPart": "",
|
||||
"TextPart": "",
|
||||
}
|
||||
)
|
||||
|
||||
conn.send_templated_email(**kwargs)
|
||||
|
||||
too_many_addresses = list("to%s@example.com" % i for i in range(51))
|
||||
|
Loading…
Reference in New Issue
Block a user