UPD: improved tests.

This commit is contained in:
2019-03-13 18:38:58 +01:00
parent c39f09709b
commit 848db26516
7 changed files with 369 additions and 52 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from django.apps import apps
from django.contrib.auth import get_user_model
from django.core import mail as django_mail
@@ -9,7 +10,7 @@ from django.urls import reverse
from ..forms import LoginForm, SetPasswordForm, ResetPasswordForm
TEST_USERNAME = 'root@localhost'
TEST_PASSWORD = 'mellon12'
TEST_PASSWORD = u'me||ön 2'
TEST_EMAIL = TEST_USERNAME
@@ -34,6 +35,7 @@ class ViewsTestCase(TestCase):
cls.set_password_message = ugettext(u'Passwort gespeichert.')
def setUp(self):
super(TestCase, self).setUp()
# Need a test user
self.test_username = TEST_USERNAME
self.test_password = TEST_PASSWORD
@@ -47,6 +49,11 @@ class ViewsTestCase(TestCase):
self.assertIn('form', response.context)
self.assertIsInstance(response.context['form'], LoginForm)
field = response.context['form'].fields['username']
self.assertTrue(field.required)
field = response.context['form'].fields['password']
self.assertTrue(field.required)
def test_integrated_login_inactive_user(self):
user = self.user
user.is_active = False
@@ -179,6 +186,9 @@ class ViewsTestCase(TestCase):
self.assertIn('form', response.context)
self.assertIsInstance(response.context['form'], ResetPasswordForm)
field = response.context['form'].fields['username']
self.assertTrue(field.required)
def test_reset_password_integrated_post(self):
location = self.reset_password_url