Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 31, 2023
1 parent 7b26052 commit 7b1e325
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any
from typing import cast

from django.conf import settings
from django.core.handlers.wsgi import WSGIRequest
from django.http import HttpResponse
from django.http.response import HttpResponseBase
Expand All @@ -14,8 +15,6 @@
from django_htmx.middleware import HtmxMiddleware
from django_htmx.middleware import redirect_middleware

from django.conf import settings


class HtmxWSGIRequest(WSGIRequest):
htmx: HtmxDetails
Expand Down Expand Up @@ -193,11 +192,14 @@ def setUp(self):
def dummy_view(self, request):
return HttpResponse()

@override_settings(LOGIN_URL='/login/', LOGIN_REDIRECT_URL='/home/')
@override_settings(LOGIN_URL="/login/", LOGIN_REDIRECT_URL="/home/")
def test_redirect_middleware(self):
request = self.factory.get("/", HTTP_HX_REQUEST="true")
response = HttpResponse(status=302)
response["Location"] = settings.LOGIN_URL
response = self.middleware(request)
assert response.status_code == 204
assert response["HX-Redirect"] == f"{settings.LOGIN_URL}?next={settings.LOGIN_REDIRECT_URL}"
assert (
response["HX-Redirect"]
== f"{settings.LOGIN_URL}?next={settings.LOGIN_REDIRECT_URL}"
)

0 comments on commit 7b1e325

Please sign in to comment.