Exemplo n.º 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]))
Exemplo n.º 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]))
Exemplo n.º 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]))
Exemplo n.º 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]))
Exemplo n.º 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': '******'})
Exemplo n.º 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': '******'})
Exemplo n.º 7
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)
Exemplo n.º 8
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')
Exemplo n.º 9
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')
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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])