Commit 3e7a1004 authored by Michal Čihař's avatar Michal Čihař

Add test for password change

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 35672bd3
......@@ -439,6 +439,41 @@ class ViewTest(TestCase):
User.objects.filter(username='testuser').exists()
)
def test_password(self):
# Create user
self.get_user()
# Login
self.client.login(username='testuser', password='testpassword')
# Change without data
response = self.client.post(
reverse('password')
)
self.assertContains(response, 'This field is required.')
# Change with wrong password
response = self.client.post(
reverse('password'),
{
'password': '123456',
'password1': '123456',
'password2': '123456'
}
)
self.assertContains(response, 'You have entered an invalid password.')
# Change
response = self.client.post(
reverse('password'),
{
'password': 'testpassword',
'password1': '123456',
'password2': '123456'
}
)
self.assertRedirects(response, reverse('profile'))
self.assertTrue(
User.objects.get(username='testuser').check_password('123456')
)
class ProfileTest(ViewTestCase):
def test_profile(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment