UPD: more test.
This commit is contained in:
0
dav_events/tests/__init__.py
Normal file
0
dav_events/tests/__init__.py
Normal file
27
dav_events/tests/test_apps.py
Normal file
27
dav_events/tests/test_apps.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from django.apps import apps
|
||||
|
||||
from dav_base.tests.generic import AppSetting, AppsTestCase
|
||||
|
||||
|
||||
class TestCase(AppsTestCase):
|
||||
app_config = apps.get_app_config('dav_events')
|
||||
|
||||
settings = (
|
||||
AppSetting('enable_email_on_status_update', bool),
|
||||
AppSetting('enable_email_on_update', bool),
|
||||
AppSetting('groups_manager_super', list),
|
||||
AppSetting('groups_manager_w', list),
|
||||
AppSetting('groups_manager_s', list),
|
||||
AppSetting('groups_manager_m', list),
|
||||
AppSetting('groups_manager_k', list),
|
||||
AppSetting('groups_manager_b', list),
|
||||
AppSetting('groups_publisher_print', list),
|
||||
AppSetting('groups_publisher_web', list),
|
||||
AppSetting('groups_publisher_facebook', list),
|
||||
AppSetting('forms_development_init', bool),
|
||||
AppSetting('form_initials', dict),
|
||||
AppSetting('matrix_config', dict),
|
||||
AppSetting('publish_before_begin_days', int),
|
||||
AppSetting('publish_before_deadline_days', int),
|
||||
AppSetting('publish_issues', list),
|
||||
)
|
||||
80
dav_events/tests/test_emails.py
Normal file
80
dav_events/tests/test_emails.py
Normal 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
|
||||
14
dav_events/tests/test_urls.py
Normal file
14
dav_events/tests/test_urls.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from dav_base.tests.generic import Url, UrlsTestCase
|
||||
|
||||
from .. import views
|
||||
|
||||
|
||||
class TestCase(UrlsTestCase):
|
||||
urls = (
|
||||
Url('/events/home', 'dav_events:root', views.base.HomeView.as_view()),
|
||||
Url('/events/', 'dav_events:list', views.events.EventListView.as_view(),
|
||||
redirect='/auth/login?next=/events/'),
|
||||
Url('/events/export', 'dav_events:list_export', views.events.EventListExportView.as_view(),
|
||||
redirect='/auth/login?next=/events/export'),
|
||||
Url('/events/create', 'dav_events:create', views.events.EventCreateView.as_view()),
|
||||
)
|
||||
Reference in New Issue
Block a user