kopia lustrzana https://github.com/wagtail/wagtail
Add tests for the password reset emails
rodzic
42a48b0085
commit
77340cfe95
|
@ -0,0 +1,33 @@
|
|||
from django.test import TestCase, override_settings
|
||||
from django.core import mail
|
||||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Site
|
||||
|
||||
|
||||
class TestUserPasswordReset(TestCase, WagtailTestUtils):
|
||||
fixtures = ['test.json']
|
||||
|
||||
# need to clear urlresolver caches before/after tests, because we override ROOT_URLCONF
|
||||
# in some tests here
|
||||
def setUp(self):
|
||||
from django.core.urlresolvers import clear_url_caches
|
||||
clear_url_caches()
|
||||
|
||||
def tearDown(self):
|
||||
from django.core.urlresolvers import clear_url_caches
|
||||
clear_url_caches()
|
||||
|
||||
@override_settings(ROOT_URLCONF="wagtail.wagtailadmin.urls")
|
||||
def test_email_found_default_url(self):
|
||||
response = self.client.post('/password_reset/', {'email': 'siteeditor@example.com'})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertIn("testserver", mail.outbox[0].body)
|
||||
|
||||
@override_settings(ROOT_URLCONF="wagtail.wagtailadmin.urls", BASE_URL='http://mysite.com')
|
||||
def test_email_found_base_url(self):
|
||||
response = self.client.post('/password_reset/', {'email': 'siteeditor@example.com'})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertIn("mysite.com", mail.outbox[0].body)
|
Ładowanie…
Reference in New Issue