'Test that celery handles transient SMTPDataErrors by retrying.'

@patch('bulk_email.tasks.get_connection', autospec=True)
@patch('bulk_email.tasks.send_course_email.retry')
def test_data_err_retry(self, retry, get_conn):

    get_conn.return_value.send_messages.side_effect = SMTPDataError(455, 'Throttling:    Sending    rate    exceeded')
    test_email = {'action': 'Send    email', 'send_to': '["myself"]', 'subject': 'test    subject    for    myself', 'message': 'test    message    for    myself'}
    response = self.client.post(self.send_mail_url, test_email)
    self.assertEquals(json.loads(response.content), self.success_content)
    self.assertTrue(retry.called)
    (__, kwargs) = retry.call_args
    exc = kwargs['exc']
    self.assertIsInstance(exc, SMTPDataError)
