Fixed #34394 -- Added FORCE_SCRIPT_NAME handling to ASGIRequest.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
sarahboyce 2023-04-10 17:10:43 +02:00 committed by Mariusz Felisiak
parent c3d7a71f83
commit 041b0a359a
2 changed files with 18 additions and 10 deletions

View file

@ -3,6 +3,7 @@ from django.core.handlers.wsgi import WSGIHandler, WSGIRequest, get_script_name
from django.core.signals import request_finished, request_started
from django.db import close_old_connections, connection
from django.test import (
AsyncRequestFactory,
RequestFactory,
SimpleTestCase,
TransactionTestCase,
@ -328,6 +329,12 @@ class AsyncHandlerRequestTests(SimpleTestCase):
with self.assertRaisesMessage(ValueError, msg):
await self.async_client.get("/unawaited/")
@override_settings(FORCE_SCRIPT_NAME="/FORCED_PREFIX/")
def test_force_script_name(self):
async_request_factory = AsyncRequestFactory()
request = async_request_factory.request(**{"path": "/somepath/"})
self.assertEqual(request.path, "/FORCED_PREFIX/somepath/")
async def test_sync_streaming(self):
response = await self.async_client.get("/streaming/")
self.assertEqual(response.status_code, 200)