UPD: dav_auth: refactor the ResetPasswordView for better name

This commit is contained in:
2020-12-22 11:51:59 +01:00
parent f3509d3a61
commit 5f296ff1c0
10 changed files with 42 additions and 35 deletions

View File

@@ -7,7 +7,7 @@ from django.test import TestCase
from django.utils.translation import ugettext
from django.urls import reverse
from ..forms import LoginForm, SetPasswordForm, ResetPasswordForm
from ..forms import LoginForm, SetPasswordForm, CreateAndSendPasswordForm
TEST_USERNAME = 'root@localhost'
TEST_PASSWORD = u'me||ön 2'
@@ -27,7 +27,7 @@ class ViewsTestCase(TestCase):
cls.logout_url = reverse('dav_auth:logout')
cls.logout_redirect_url = resolve_url(cls.app_settings.logout_redirect_url)
cls.set_password_url = reverse('dav_auth:set_password')
cls.reset_password_url = reverse('dav_auth:reset_password')
cls.recreate_password_url = reverse('dav_auth:recreate_password')
# Some messages
cls.wrong_credentials_message = ugettext(u'Benutzername oder Passwort falsch.')
@@ -179,23 +179,23 @@ class ViewsTestCase(TestCase):
self.assertFalse(self.client.login(username=username, password=password), 'Old password still valid')
self.assertTrue(self.client.login(username=username, password=new_password), 'New password not valid')
def test_reset_password_integrated_unauth_get(self):
response = self.client.get(self.reset_password_url)
def test_recreate_password_integrated_unauth_get(self):
response = self.client.get(self.recreate_password_url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'dav_auth/forms/reset_password.html')
self.assertTemplateUsed(response, 'dav_auth/forms/recreate_password.html')
self.assertIn('form', response.context)
self.assertIsInstance(response.context['form'], ResetPasswordForm)
self.assertIsInstance(response.context['form'], CreateAndSendPasswordForm)
field = response.context['form'].fields['username']
self.assertTrue(field.required)
def test_reset_password_integrated_auth_get(self):
def test_recreate_password_integrated_auth_get(self):
self.client.login(username=self.test_username, password=self.test_password)
response = self.client.get(self.reset_password_url)
response = self.client.get(self.recreate_password_url)
self.assertRedirects(response, self.set_password_url)
def test_reset_password_integrated_post(self):
location = self.reset_password_url
def test_recreate_password_integrated_post(self):
location = self.recreate_password_url
response = self.client.post(location, {'username': self.user.username})
self.assertRedirects(response, self.login_url)