mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-07 10:58:25 +02:00
Add black code formatter
This commit is contained in:
@@ -7,49 +7,51 @@ from bookmarks.tests.helpers import BookmarkFactoryMixin
|
||||
|
||||
class PasswordChangeViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
def setUp(self) -> None:
|
||||
self.user = User.objects.create_user('testuser', 'test@example.com', 'initial_password')
|
||||
self.user = User.objects.create_user(
|
||||
"testuser", "test@example.com", "initial_password"
|
||||
)
|
||||
self.client.force_login(self.user)
|
||||
|
||||
def test_change_password(self):
|
||||
form_data = {
|
||||
'old_password': 'initial_password',
|
||||
'new_password1': 'new_password',
|
||||
'new_password2': 'new_password',
|
||||
"old_password": "initial_password",
|
||||
"new_password1": "new_password",
|
||||
"new_password2": "new_password",
|
||||
}
|
||||
|
||||
response = self.client.post(reverse('change_password'), form_data)
|
||||
response = self.client.post(reverse("change_password"), form_data)
|
||||
|
||||
self.assertRedirects(response, reverse('password_change_done'))
|
||||
self.assertRedirects(response, reverse("password_change_done"))
|
||||
|
||||
def test_change_password_done(self):
|
||||
form_data = {
|
||||
'old_password': 'initial_password',
|
||||
'new_password1': 'new_password',
|
||||
'new_password2': 'new_password',
|
||||
"old_password": "initial_password",
|
||||
"new_password1": "new_password",
|
||||
"new_password2": "new_password",
|
||||
}
|
||||
|
||||
response = self.client.post(reverse('change_password'), form_data, follow=True)
|
||||
response = self.client.post(reverse("change_password"), form_data, follow=True)
|
||||
|
||||
self.assertContains(response, 'Your password was changed successfully')
|
||||
self.assertContains(response, "Your password was changed successfully")
|
||||
|
||||
def test_should_return_error_for_invalid_old_password(self):
|
||||
form_data = {
|
||||
'old_password': 'wrong_password',
|
||||
'new_password1': 'new_password',
|
||||
'new_password2': 'new_password',
|
||||
"old_password": "wrong_password",
|
||||
"new_password1": "new_password",
|
||||
"new_password2": "new_password",
|
||||
}
|
||||
|
||||
response = self.client.post(reverse('change_password'), form_data)
|
||||
response = self.client.post(reverse("change_password"), form_data)
|
||||
|
||||
self.assertIn('old_password', response.context_data['form'].errors)
|
||||
self.assertIn("old_password", response.context_data["form"].errors)
|
||||
|
||||
def test_should_return_error_for_mismatching_new_password(self):
|
||||
form_data = {
|
||||
'old_password': 'initial_password',
|
||||
'new_password1': 'new_password',
|
||||
'new_password2': 'wrong_password',
|
||||
"old_password": "initial_password",
|
||||
"new_password1": "new_password",
|
||||
"new_password2": "wrong_password",
|
||||
}
|
||||
|
||||
response = self.client.post(reverse('change_password'), form_data)
|
||||
response = self.client.post(reverse("change_password"), form_data)
|
||||
|
||||
self.assertIn('new_password2', response.context_data['form'].errors)
|
||||
self.assertIn("new_password2", response.context_data["form"].errors)
|
||||
|
Reference in New Issue
Block a user