UPD: More and better tests.
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
from django.apps import apps
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||
from django.core import mail as django_mail
|
||||
from django.test import SimpleTestCase, TestCase, tag
|
||||
from django.urls import reverse
|
||||
from selenium import webdriver
|
||||
@@ -44,6 +45,15 @@ class EmailTestMixin(object):
|
||||
email_base_url = 'http://localhost'
|
||||
email_subject_prefix = '[Test]'
|
||||
|
||||
def get_mail_for_user(self, user):
|
||||
recipient = '"{fullname}" <{email}>'.format(fullname=user.get_full_name(), email=user.email)
|
||||
mails = []
|
||||
for mail in django_mail.outbox:
|
||||
if recipient in mail.recipients():
|
||||
mails.append(mail)
|
||||
|
||||
return mails
|
||||
|
||||
def assertSender(self, mail):
|
||||
self.assertEqual(mail.from_email, self.email_sender)
|
||||
|
||||
|
||||
@@ -35,9 +35,10 @@ class TemplatesTestCase(SimpleTestCase):
|
||||
'<script type="text/javascript" src="{static_url}dav_base/bootstrap/js/bootstrap.min.js"></script>',
|
||||
)
|
||||
|
||||
content = response.content.decode('utf-8')
|
||||
for needle in html_needles:
|
||||
needle = needle.format(static_url=static_url)
|
||||
self.assertInHTML(needle, response.content.decode('utf-8'))
|
||||
self.assertInHTML(needle, content)
|
||||
|
||||
def test_page_footer(self):
|
||||
response = self.response_from_root_view
|
||||
|
||||
Reference in New Issue
Block a user