-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0418c2d
commit 11e91d0
Showing
3 changed files
with
41 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,12 @@ | ||
from __future__ import annotations | ||
|
||
from django.http import Http404 | ||
from django.http import HttpResponse | ||
from django.urls import path | ||
|
||
|
||
def test_view(request): | ||
if request.method != "GET": | ||
raise Http404() | ||
return HttpResponse("Test view") | ||
|
||
|
||
async def async_(request): | ||
return HttpResponse("Test view") | ||
|
||
|
||
def test_view_http401(request): | ||
return HttpResponse("Unauthorized", status=401) | ||
|
||
|
||
def test_view_that_deletes_is_enabled(request): | ||
del request._cors_enabled | ||
return HttpResponse() | ||
|
||
from tests import views | ||
|
||
urlpatterns = [ | ||
path("", test_view), | ||
path("foo/", test_view), | ||
path("async/", async_), | ||
path("test-401/", test_view_http401), | ||
path("delete-is-enabled/", test_view_that_deletes_is_enabled), | ||
path("", views.index), | ||
path("async/", views.async_), | ||
path("unauthorized/", views.unauthorized), | ||
path("delete-enabled/", views.delete_enabled_attribute), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from http import HTTPStatus | ||
|
||
from django.http import HttpResponse | ||
from django.views.decorators.http import require_GET | ||
|
||
|
||
@require_GET | ||
def index(request): | ||
return HttpResponse("Index") | ||
|
||
|
||
async def async_(request): | ||
return HttpResponse("Asynchronous") | ||
|
||
|
||
def unauthorized(request): | ||
return HttpResponse("Unauthorized", status=HTTPStatus.UNAUTHORIZED) | ||
|
||
|
||
def delete_enabled_attribute(request): | ||
del request._cors_enabled | ||
return HttpResponse() |