mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
Updates tests
This commit is contained in:
parent
f44b3cc4b2
commit
a0e01af2ca
1 changed files with 37 additions and 4 deletions
|
@ -42,17 +42,50 @@ class ChangePasswordViews(TestCase):
|
|||
"""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)
|
||||
|
|
Loading…
Reference in a new issue