mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Correct name/content lists for template_content, merge_vars, global_merge_vars.
Fixes #24.
This commit is contained in:
@@ -173,12 +173,12 @@ class DjrillBackend(BaseEmailBackend):
|
||||
|
||||
|
||||
def _expand_merge_vars(self, vars):
|
||||
"""Convert a Python dict to an array of name-value used by Mandrill.
|
||||
"""Convert a Python dict to an array of name-content used by Mandrill.
|
||||
|
||||
{ name: value, ... } --> [ {'name': name, 'value': value }, ... ]
|
||||
{ name: value, ... } --> [ {'name': name, 'content': value }, ... ]
|
||||
"""
|
||||
# For testing reproducibility, we sort the keys
|
||||
return [ { 'name': name, 'value': vars[name] }
|
||||
return [ { 'name': name, 'content': vars[name] }
|
||||
for name in sorted(vars.keys()) ]
|
||||
|
||||
def _add_alternatives(self, message, msg_dict):
|
||||
|
||||
@@ -249,7 +249,7 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
|
||||
self.assertEqual(data['message']['preserve_recipients'], True)
|
||||
|
||||
def test_merge(self):
|
||||
# Djrill expands simple python dicts into the more-verbose name/value
|
||||
# Djrill expands simple python dicts into the more-verbose name/content
|
||||
# structures the Mandrill API uses
|
||||
self.message.global_merge_vars = { 'GREETING': "Hello",
|
||||
'ACCOUNT_TYPE': "Basic" }
|
||||
@@ -261,14 +261,14 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
|
||||
self.message.send()
|
||||
data = self.get_api_call_data()
|
||||
self.assertEqual(data['message']['global_merge_vars'],
|
||||
[ {'name': 'ACCOUNT_TYPE', 'value': "Basic"},
|
||||
{'name': "GREETING", 'value': "Hello"} ])
|
||||
[ {'name': 'ACCOUNT_TYPE', 'content': "Basic"},
|
||||
{'name': "GREETING", 'content': "Hello"} ])
|
||||
self.assertEqual(data['message']['merge_vars'],
|
||||
[ { 'rcpt': "customer@example.com",
|
||||
'vars': [{ 'name': 'ACCOUNT_TYPE', 'value': "Premium" },
|
||||
{ 'name': "GREETING", 'value': "Dear Customer"}] },
|
||||
'vars': [{ 'name': 'ACCOUNT_TYPE', 'content': "Premium" },
|
||||
{ 'name': "GREETING", 'content': "Dear Customer"}] },
|
||||
{ 'rcpt': "guest@example.com",
|
||||
'vars': [{ 'name': "GREETING", 'value': "Dear Guest"}] }
|
||||
'vars': [{ 'name': "GREETING", 'content': "Dear Guest"}] }
|
||||
])
|
||||
|
||||
def test_tags(self):
|
||||
@@ -291,7 +291,7 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
|
||||
self.message.metadata = { 'batch_num': "12345", 'type': "Receipts" }
|
||||
self.message.recipient_metadata = {
|
||||
# Djrill expands simple python dicts into the more-verbose
|
||||
# name/value structures the Mandrill API uses
|
||||
# rcpt/values structures the Mandrill API uses
|
||||
"customer@example.com": { 'cust_id': "67890", 'order_id': "54321" },
|
||||
"guest@example.com": { 'cust_id': "94107", 'order_id': "43215" }
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ class DjrillMandrillSendTemplateTests(DjrillBackendMockAPITestCase):
|
||||
self.assert_mandrill_called("/messages/send-template.json")
|
||||
data = self.get_api_call_data()
|
||||
self.assertEqual(data['template_name'], "PERSONALIZED_SPECIALS")
|
||||
# Djrill expands simple python dicts into the more-verbose name/value
|
||||
# Djrill expands simple python dicts into the more-verbose name/content
|
||||
# structures the Mandrill API uses
|
||||
self.assertEqual(data['template_content'],
|
||||
[ {'name': "HEADLINE",
|
||||
'value': "<h1>Specials Just For *|FNAME|*</h1>"},
|
||||
'content': "<h1>Specials Just For *|FNAME|*</h1>"},
|
||||
{'name': "OFFER_BLOCK",
|
||||
'value': "<p><em>Half off</em> all fruit</p>"} ]
|
||||
'content': "<p><em>Half off</em> all fruit</p>"} ]
|
||||
)
|
||||
|
||||
def test_no_template_content(self):
|
||||
|
||||
Reference in New Issue
Block a user