From 9968c68b7450d57341d36df223b6b3bb91acd466 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Tue, 10 Dec 2019 14:14:34 +0100 Subject: [PATCH] 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 --- ivatar/ivataraccount/test_views.py | 31 +++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/ivatar/ivataraccount/test_views.py b/ivatar/ivataraccount/test_views.py index 0d90625..7eedad9 100644 --- a/ivatar/ivataraccount/test_views.py +++ b/ivatar/ivataraccount/test_views.py @@ -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