SendGrid: Set to field when using merge_data (#14)

* Set to field when using merge_data

The `to` field is required even if providing recipient addresses in x-smtpapi. See https://sendgrid.com/docs/API_Reference/Web_API/mail.html#-send.

* Check data['to'] contains expected emails

* Add space for toname check

* Make `to` expected data contain email only
This commit is contained in:
Lewis Taylor
2016-05-18 19:01:54 +01:00
committed by Mike Edmunds
parent 23becd35a9
commit 72d899460c
2 changed files with 3 additions and 2 deletions

View File

@@ -431,8 +431,8 @@ class SendGridBackendAnymailFeatureTests(SendGridBackendMockAPITestCase):
data = self.get_api_call_data()
smtpapi = self.get_smtpapi()
self.assertNotIn('to', data) # recipients should be moved to smtpapi-to with merge_data
self.assertNotIn('toname', data)
self.assertEqual(data['toname'], [' ', 'Bob'])
self.assertEqual(data['to'], ['alice@example.com', 'bob@example.com'])
self.assertEqual(smtpapi['to'], ['alice@example.com', 'Bob <bob@example.com>'])
self.assertEqual(smtpapi['sub'], {
':name': ["Alice", "Bob"],