Files
django-dav-events/dav_base/tests/test_emails.py

44 lines
1.2 KiB
Python

from django.core import mail as django_mail
from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase
from ..emails import AbstractMail
from .generic import EmailTestMixin
class TestCase(EmailTestMixin, SimpleTestCase):
def test_no_template_configured(self):
class ConcreteMail(AbstractMail):
pass
email = ConcreteMail()
with self.assertRaises(ImproperlyConfigured):
email.send()
def test_no_get_recipients_implemented(self):
class ConcreteMail(AbstractMail):
_template_name = 'dav_base/base.html'
email = ConcreteMail()
with self.assertRaises(NotImplementedError):
email.send()
def test_send(self):
recipient = 'root@localhost'
class ConcreteMail(AbstractMail):
_template_name = 'dav_base/base.html'
def _get_recipients(self):
return [recipient]
email = ConcreteMail()
email.send()
self.assertEqual(len(django_mail.outbox), 1)
mail = django_mail.outbox[0]
self.assertSender(mail)
self.assertRecipients(mail, [recipient])
self.assertSubject(mail, u'')