summaryrefslogtreecommitdiff
path: root/tests/staticfiles_tests
diff options
context:
space:
mode:
authorJoshua Massover <massover@simplebet.io>2020-05-14 19:26:32 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-08 12:52:26 +0200
commit92309e53d9921a60e667656d8dd65e59eb5cf81c (patch)
tree24c95e6915a68810437a66a20610dfb0bd9db279 /tests/staticfiles_tests
parent4652f1f0aa459a7b980441d629648707c32e36bf (diff)
downloaddjango-92309e53d9921a60e667656d8dd65e59eb5cf81c.tar.gz
Fixed #31594 -- Added ASGIStaticFilesHandler.get_response_async().
Diffstat (limited to 'tests/staticfiles_tests')
-rw-r--r--tests/staticfiles_tests/test_handlers.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/staticfiles_tests/test_handlers.py b/tests/staticfiles_tests/test_handlers.py
new file mode 100644
index 0000000000..4cd5811d88
--- /dev/null
+++ b/tests/staticfiles_tests/test_handlers.py
@@ -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)