mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #31594 -- Added ASGIStaticFilesHandler.get_response_async().
This commit is contained in:
parent
4652f1f0aa
commit
92309e53d9
4 changed files with 78 additions and 1 deletions
22
tests/staticfiles_tests/test_handlers.py
Normal file
22
tests/staticfiles_tests/test_handlers.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler
|
||||
from django.core.handlers.asgi import ASGIHandler
|
||||
from django.test import AsyncRequestFactory
|
||||
|
||||
from .cases import StaticFilesTestCase
|
||||
|
||||
|
||||
class TestASGIStaticFilesHandler(StaticFilesTestCase):
|
||||
async_request_factory = AsyncRequestFactory()
|
||||
|
||||
async def test_get_async_response(self):
|
||||
request = self.async_request_factory.get('/static/test/file.txt')
|
||||
handler = ASGIStaticFilesHandler(ASGIHandler())
|
||||
response = await handler.get_response_async(request)
|
||||
response.close()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
async def test_get_async_response_not_found(self):
|
||||
request = self.async_request_factory.get('/static/test/not-found.txt')
|
||||
handler = ASGIStaticFilesHandler(ASGIHandler())
|
||||
response = await handler.get_response_async(request)
|
||||
self.assertEqual(response.status_code, 404)
|
Loading…
Add table
Add a link
Reference in a new issue