Beispiel #1
0
 def test_send_single_email_object(self):
     """ It should accept and send a single EmailMessage object. """
     msg = mail.EmailMessage()
     tasks.send_email(msg, backend_kwargs={})
     self.assertEqual(len(mail.outbox), 1)
     # we can't compare them directly as it's converted into a dict
     # for JSONification and then back. Compare dicts instead.
     self.assertEqual(email_to_dict(msg), email_to_dict(mail.outbox[0]))
Beispiel #2
0
 def test_send_single_email_dict(self):
     """ It should accept and send a single EmailMessage dict. """
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), backend_kwargs={})
     self.assertEqual(len(mail.outbox), 1)
     # we can't compare them directly as it's converted into a dict
     # for JSONification and then back. Compare dicts instead.
     self.assertEqual(email_to_dict(msg), email_to_dict(mail.outbox[0]))
Beispiel #3
0
 def test_send_single_email_object_no_backend_kwargs(self):
     """ It should send email with backend_kwargs not provided. """
     msg = mail.EmailMessage()
     tasks.send_email(msg)
     self.assertEqual(len(mail.outbox), 1)
     # we can't compare them directly as it's converted into a dict
     # for JSONification and then back. Compare dicts instead.
     self.assertEqual(email_to_dict(msg), email_to_dict(mail.outbox[0]))
Beispiel #4
0
 def test_send_single_email_object_no_backend_kwargs(self):
     """ It should send email with backend_kwargs not provided. """
     msg = mail.EmailMessage()
     tasks.send_email(msg)
     self.assertEqual(len(mail.outbox), 1)
     # we can't compare them directly as it's converted into a dict
     # for JSONification and then back. Compare dicts instead.
     self.assertEqual(email_to_dict(msg), email_to_dict(mail.outbox[0]))
Beispiel #5
0
 def test_custom_backend(self):
     message = mail.EmailMessage('test', 'Testing with Celery! w00t!!',
                                 '*****@*****.**', ['*****@*****.**'])
     result = send_email(message, backend='test_project.tester.tests.TestBackend',
                         _backend_init_kwargs={
                            'username': '******',
                            'password': '******'
                         })
     self.assertEqual(result, {'username': '******', 'password': '******'})
Beispiel #6
0
 def test_custom_backend(self):
     message = mail.EmailMessage('test', 'Testing with Celery! w00t!!',
                                 '*****@*****.**', ['*****@*****.**'])
     result = send_email(message,
                         backend='test_project.tester.tests.TestBackend',
                         _backend_init_kwargs={
                             'username': '******',
                             'password': '******'
                         })
     self.assertEqual(result, {'username': '******', 'password': '******'})
 def test_send_single_email_object_response(self):
     """ It should return the number of messages sent, 1 here. """
     msg = mail.EmailMessage()
     messages_sent = tasks.send_email(msg)
     self.assertEqual(messages_sent, 1)
     self.assertEqual(len(mail.outbox), 1)
 def test_backend_parameters_kwargs(self):
     """ It should pass on kwargs specified as keyword params. """
     TracingBackend.kwargs = None
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), foo='bar')
     self.assertEqual(TracingBackend.kwargs.get('foo'), 'bar')
 def test_backend_parameters(self):
     """ It should pass kwargs like username and password to the backend. """
     TracingBackend.kwargs = None
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), backend_kwargs={'foo': 'bar'})
     self.assertEqual(TracingBackend.kwargs.get('foo'), 'bar')
Beispiel #10
0
 def test_uses_correct_backend(self):
     """ It should use the backend configured in CELERY_EMAIL_BACKEND. """
     TracingBackend.called = False
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), backend_kwargs={})
     self.assertTrue(TracingBackend.called)
Beispiel #11
0
 def test_send_single_email_object_response(self):
     """ It should return the number of messages sent, 1 here. """
     msg = mail.EmailMessage()
     messages_sent = tasks.send_email(msg)
     self.assertEqual(messages_sent, 1)
     self.assertEqual(len(mail.outbox), 1)
Beispiel #12
0
 def test_backend_parameters_kwargs(self):
     """ It should pass on kwargs specified as keyword params. """
     TracingBackend.kwargs = None
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), foo='bar')
     self.assertEqual(TracingBackend.kwargs.get('foo'), 'bar')
Beispiel #13
0
 def test_backend_parameters(self):
     """ It should pass kwargs like username and password to the backend. """
     TracingBackend.kwargs = None
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), backend_kwargs={'foo': 'bar'})
     self.assertEqual(TracingBackend.kwargs.get('foo'), 'bar')
Beispiel #14
0
 def test_uses_correct_backend(self):
     """ It should use the backend configured in CELERY_EMAIL_BACKEND. """
     TracingBackend.called = False
     msg = mail.EmailMessage()
     tasks.send_email(email_to_dict(msg), backend_kwargs={})
     self.assertTrue(TracingBackend.called)
Beispiel #15
0
 def test_send_single_email(self):
     """ It should accept and send a single EmailMessage object. """
     msg = mail.EmailMessage()
     tasks.send_email(msg, backend_kwargs={})
     self.assertEqual(len(mail.outbox), 1)
     self.assertTrue(msg is mail.outbox[0])