Add test for common password and adapt expected text for wrong pw, since Django 3 seems to return Unicode. Also fix exptected URL in some test

This commit is contained in:
Oliver Falk
2019-12-10 14:14:34 +01:00
parent ed858d4c81
commit 9968c68b74

View File

@@ -1228,7 +1228,7 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
response = self.client.get(url, follow=True)
self.assertRedirects(
response=response,
expected_url='/gravatarproxy/1b1d0b654430c012e47e350db07c83c5?s=80&default=mm',
expected_url='/static/img/mm/80.png',
msg_prefix='Why does this not redirect to the gravatarproxy and defaulting to mm?')
# Eventually one should check if the data is the same
@@ -1431,13 +1431,12 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
},
follow=True,
)
self.assertContains(
response,
'The two password fields didn't match.',
'The two password fields didn',
1,
200,
'Old password as entered incorrectly, site should raise an error'
'Old password was entered incorrectly, site should raise an error'
)
def test_password_change_view_post_wrong_new_password2(self):
@@ -1456,12 +1455,34 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
self.assertContains(
response,
'The two password fields didn't match.',
'The two password fields didn',
1,
200,
'Old password as entered incorrectly, site should raise an error'
)
def test_password_change_view_post_common_password(self):
'''
Test password change view post
'''
self.login()
response = self.client.post(
reverse('password_change'), {
'old_password': self.password,
'new_password1': 'Hallo',
'new_password2': 'Hallo',
},
follow=True,
)
self.assertContains(
response,
'This password is too common.',
1,
200,
'Common password, site should raise an error'
)
def test_profile_must_list_first_and_lastname(self):
'''
Test if profile view correctly lists first -/last name