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
Some checks failed
Run tests / Execute tox to run the test suite (push) Failing after 1m26s
This commit is contained in:
@@ -171,6 +171,8 @@ class Url: # pylint: disable=too-few-public-methods
|
||||
self.location = location
|
||||
self.name = name
|
||||
self.func = func
|
||||
self.http_method = kwargs.get('http_method', "GET")
|
||||
self.post_data = kwargs.get('post_data', {})
|
||||
self.redirect = kwargs.get('redirect', False)
|
||||
self.status_code = kwargs.get('status_code', 200)
|
||||
self.follow = kwargs.get('follow', False)
|
||||
@@ -182,7 +184,12 @@ class UrlsTestCase(TestCase):
|
||||
def test_locations(self):
|
||||
for url in self.urls:
|
||||
if url.location:
|
||||
response = self.client.get(url.location, follow=url.follow)
|
||||
if url.http_method == "GET":
|
||||
response = self.client.get(url.location, follow=url.follow)
|
||||
elif url.http_method == "POST":
|
||||
response = self.client.post(url.location, data=url.post_data, follow=url.follow)
|
||||
else: # pragma: no cover
|
||||
raise NotImplementedError("Method {} is not supported".format(url.http_method))
|
||||
|
||||
if url.redirect:
|
||||
self.assertRedirects(response, url.redirect)
|
||||
@@ -198,7 +205,13 @@ class UrlsTestCase(TestCase):
|
||||
def test_names(self):
|
||||
for url in self.urls:
|
||||
if url.name:
|
||||
response = self.client.get(reverse(url.name), follow=url.follow)
|
||||
location = reverse(url.name)
|
||||
if url.http_method == "GET":
|
||||
response = self.client.get(location, follow=url.follow)
|
||||
elif url.http_method == "POST":
|
||||
response = self.client.post(location, data=url.post_data, follow=url.follow)
|
||||
else: # pragma: no cover
|
||||
raise NotImplementedError("Method {} is not supported".format(url.http_method))
|
||||
|
||||
if url.redirect:
|
||||
self.assertRedirects(response, url.redirect)
|
||||
|
||||
Reference in New Issue
Block a user