mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
SparkPost: remove empty content params with template_id
When using a stored template, SparkPost disallows subject, text, and html. Django's EmailMessage default empty strings are enough to provoke "Both content object and template_id are specified" from SparkPost, so remove them (if empty) when using stored templates. Update docs and tests; add integration test for template_id. Fixes #24
This commit is contained in:
@@ -390,10 +390,15 @@ class SparkPostBackendAnymailFeatureTests(SparkPostBackendMockAPITestCase):
|
||||
self.assertEqual(params['track_clicks'], True)
|
||||
|
||||
def test_template_id(self):
|
||||
self.message.template_id = "welcome_template"
|
||||
self.message.send()
|
||||
message = mail.EmailMultiAlternatives(from_email='from@example.com', to=['to@example.com'])
|
||||
message.template_id = "welcome_template"
|
||||
message.send()
|
||||
params = self.get_send_params()
|
||||
self.assertEqual(params['template'], "welcome_template")
|
||||
# SparkPost disallows all content (even empty strings) with stored template:
|
||||
self.assertNotIn('subject', params)
|
||||
self.assertNotIn('text', params)
|
||||
self.assertNotIn('html', params)
|
||||
|
||||
def test_merge_data(self):
|
||||
self.set_mock_response(accepted=2)
|
||||
|
||||
Reference in New Issue
Block a user