Django 5: LogoutView must be called via POST now
Some checks failed
Run tests / Execute tox to run the test suite (push) Failing after 1m26s

This commit is contained in:
2025-04-11 09:37:12 +02:00
parent 86dadac421
commit e5c1bbed4b
9 changed files with 39 additions and 13 deletions

View File

@@ -61,7 +61,7 @@ class ViewsTestCase(TestCase):
response = self.client.post(self.login_url, {'username': self.test_username, 'password': self.test_password})
self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', None, self.wrong_credentials_message)
self.assertFormError(response.context['form'], None, self.wrong_credentials_message)
self.assertFalse(response.context['user'].is_authenticated, 'User is logged in')
def test_integrated_login_fail_with_wrong_credentials(self):
@@ -69,7 +69,7 @@ class ViewsTestCase(TestCase):
response = self.client.post(self.login_url, {'username': self.test_username, 'password': wrong_password})
self.assertEqual(response.status_code, 200)
self.assertFormError(response, 'form', None, self.wrong_credentials_message)
self.assertFormError(response.context['form'],None, self.wrong_credentials_message)
self.assertFalse(response.context['user'].is_authenticated, 'User is logged in')
def test_integrated_login_succeed(self):
@@ -88,7 +88,7 @@ class ViewsTestCase(TestCase):
def test_integrated_logout(self):
self.client.login(username=self.test_username, password=self.test_password)
response = self.client.get(self.logout_url)
response = self.client.post(self.logout_url)
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, self.logout_redirect_url)