Use real Response object in DjrillBackendMockAPITestCase tests.

(Improves testing accuracy around API response encoding.)

* Add `six` as test dependency (six.BytesIO, six.b)
* Change MockResponse content to bytes (because HTTP responses
  are bytes, not strings)
This commit is contained in:
medmunds
2015-01-16 13:18:17 -08:00
parent 4754ef7650
commit 11961b57e5
4 changed files with 13 additions and 10 deletions

View File

@@ -6,7 +6,9 @@ from base64 import b64decode
from datetime import date, datetime, timedelta, tzinfo
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
import json
import os
import six
from django.core import mail
from django.core.exceptions import ImproperlyConfigured
@@ -466,7 +468,7 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
def test_send_attaches_mandrill_response(self):
""" The mandrill_response should be attached to the message when it is sent """
response = [{'mandrill_response': 'would_be_here'}]
self.mock_post.return_value = self.MockResponse(json=response)
self.mock_post.return_value = self.MockResponse(raw=six.b(json.dumps(response)))
msg = mail.EmailMessage('Subject', 'Message', 'from@example.com', ['to1@example.com'],)
sent = msg.send()
self.assertEqual(sent, 1)