1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #34100 -- Made file upload tests use Storage.exists() where appropriate.

This commit is contained in:
Francesco Panico
2022-12-30 12:47:59 +01:00
committed by Mariusz Felisiak
parent 6e9e7ec472
commit c179ad9fe7
4 changed files with 17 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ from django.core.files.uploadhandler import TemporaryFileUploadHandler
from django.http import HttpResponse, HttpResponseServerError, JsonResponse
from .models import FileModel
from .tests import UNICODE_FILENAME, UPLOAD_TO
from .tests import UNICODE_FILENAME, UPLOAD_FOLDER
from .uploadhandler import (
ErroringUploadHandler,
QuotaUploadHandler,
@@ -68,9 +68,13 @@ def file_upload_unicode_name(request):
# Check to make sure the exotic characters are preserved even
# through file save.
uni_named_file = request.FILES["file_unicode"]
FileModel.objects.create(testfile=uni_named_file)
full_name = "%s/%s" % (UPLOAD_TO, uni_named_file.name)
return HttpResponse() if os.path.exists(full_name) else HttpResponseServerError()
file_model = FileModel.objects.create(testfile=uni_named_file)
full_name = f"{UPLOAD_FOLDER}/{uni_named_file.name}"
return (
HttpResponse()
if file_model.testfile.storage.exists(full_name)
else HttpResponseServerError()
)
def file_upload_echo(request):