Skip to content

Commit

Permalink
Updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mouse-reeve committed Jul 11, 2022
1 parent f44b3cc commit a0e01af
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions bookwyrm/tests/views/preferences/test_change_password.py
Expand Up @@ -42,17 +42,50 @@ def test_password_change(self):
"""change password"""
view = views.ChangePassword.as_view()
password_hash = self.local_user.password
request = self.factory.post("", {"password": "hi", "confirm-password": "hi"})
request = self.factory.post(
"",
{
"current_password": "password",
"password": "hi",
"confirm-password": "hi",
},
)
request.user = self.local_user
with patch("bookwyrm.views.preferences.change_password.login"):
view(request)
result = view(request)
validate_html(result.render())
self.assertNotEqual(self.local_user.password, password_hash)

def test_password_change_wrong_current(self):
"""change password"""
view = views.ChangePassword.as_view()
password_hash = self.local_user.password
request = self.factory.post(
"",
{
"current_password": "not my password",
"password": "hi",
"confirm-password": "hihi",
},
)
request.user = self.local_user
result = view(request)
validate_html(result.render())
self.assertEqual(self.local_user.password, password_hash)

def test_password_change_mismatch(self):
"""change password"""
view = views.ChangePassword.as_view()
password_hash = self.local_user.password
request = self.factory.post("", {"password": "hi", "confirm-password": "hihi"})
request = self.factory.post(
"",
{
"current_password": "password",
"password": "hi",
"confirm-password": "hihi",
},
)
request.user = self.local_user
view(request)
result = view(request)
validate_html(result.render())
self.assertEqual(self.local_user.password, password_hash)

0 comments on commit a0e01af

Please sign in to comment.