UPD: more test.

This commit is contained in:
2019-03-14 15:36:09 +01:00
parent 3f68579b78
commit 2dce52cb25
10 changed files with 171 additions and 28 deletions

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
from django.contrib.auth import get_user_model
from django.core import mail as django_mail
from django.test import TestCase
from django.utils import timezone
from ..models.event import Event
from .. import emails
class EmailsTestCase(TestCase):
def setUp(self):
model = get_user_model()
self.recipient = model.objects.create_user(username='recipient@example.com',
email='recipient@example.com',
password=u'mellon12',
first_name=u'Re Ö.',
last_name=u'Cipient',
)
self.editor = model.objects.create_user(username='editor@example.com',
email='editor@example.com',
password=u'mellon12',
first_name=u'Ed Ü.',
last_name=u'Itor',
)
event_data = {
'title': u'Täst',
'description': u'Teßt',
'mode': 'joint',
'sport': 'W',
'level': 'beginner',
'first_day': timezone.now(),
'country': 'DE',
'owner': self.editor,
}
self.event = Event(**event_data)
self.event.save()
self.diff = u"""---
+++
@@ -1,3 +1,3 @@
Line 1 ä
-Line2
+Line 2
Line 3 END"""
def test_event_updated_mail(self):
email = emails.EventUpdatedMail(recipient=self.recipient, event=self.event, editor=self.editor,
diff=self.diff)
email.send()
self.assertEqual(len(django_mail.outbox), 1)
mail = django_mail.outbox[0]
recipient = u'"%s" <%s>' % (self.recipient.get_full_name(), self.recipient.email)
recipients = mail.recipients()
self.assertIn(recipient, recipients)
self.assertEqual(len(recipients), 1)
self.assertIn(self.recipient.first_name, mail.body)
self.assertIn(self.editor.get_full_name(), mail.body)
self.assertIn(unicode(self.event), mail.body)
self.assertIn(self.diff, mail.body)
def test_event_submitted_mail(self):
# TODO
pass
def test_event_to_accept_mail(self):
# TODO
pass
def test_accepted_mail(self):
# TODO
pass
def test_event_to_publish_web_mail(self):
# TODO
pass
def test_event_to_publish_facebook_mail(self):
# TODO
pass