Add black code formatter

This commit is contained in:
Sascha Ißbrücker
2024-01-27 11:29:16 +01:00
parent 6775633be5
commit 98b9a9c1a0
128 changed files with 7181 additions and 4264 deletions

View File

@@ -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)