-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore(): Add Django test, simplify Django async test app
- Loading branch information
1 parent
37333e2
commit b132e1a
Showing
4 changed files
with
25 additions
and
77 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
29 changes: 1 addition & 28 deletions
29
examples/django/django_async_app/django_async_app/testing/views.py
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,39 +1,12 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
import os | ||
import time | ||
|
||
from django.conf import settings | ||
from django.contrib.auth import authenticate | ||
from django.contrib.auth.models import User | ||
from django.http import HttpResponse, JsonResponse | ||
|
||
|
||
def environ(request): | ||
return JsonResponse(dict(os.environ)) | ||
|
||
|
||
def user_count(request): | ||
return JsonResponse(User.objects.count(), safe=False) | ||
|
||
|
||
def get_settings(request, name): | ||
if hasattr(settings, name): | ||
return JsonResponse(getattr(settings, name), safe=False) | ||
else: | ||
return JsonResponse({"error": f"settings {name!r} not found"}, status=404) | ||
from django.http import HttpResponse | ||
|
||
|
||
def sleep(request): | ||
duration = request.GET.get("duration") | ||
time.sleep(int(duration)) | ||
return HttpResponse() | ||
|
||
|
||
def login(request): | ||
user = authenticate(username=request.GET.get("username"), password=request.GET.get("password")) | ||
if user is not None: | ||
return HttpResponse(status=200) | ||
else: | ||
return HttpResponse(status=403) |
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