MCPcopy
hub / github.com/django/django / test_get_asgi_application

Method test_get_asgi_application

tests/asgi/tests.py:58–82  ·  view source on GitHub ↗

get_asgi_application() returns a functioning ASGI callable.

(self)

Source from the content-addressed store, hash-verified

56 self.addCleanup(request_started.connect, close_old_connections)
57
58 async def test_get_asgi_application(self):
59 """
60 get_asgi_application() returns a functioning ASGI callable.
61 """
62 application = get_asgi_application()
63 # Construct HTTP request.
64 scope = self.async_request_factory._base_scope(path="/")
65 communicator = ApplicationCommunicator(application, scope)
66 await communicator.send_input({"type": "http.request"})
67 # Read the response.
68 response_start = await communicator.receive_output()
69 self.assertEqual(response_start["type"], "http.response.start")
70 self.assertEqual(response_start["status"], 200)
71 self.assertEqual(
72 set(response_start["headers"]),
73 {
74 (b"Content-Length", b"12"),
75 (b"Content-Type", b"text/html; charset=utf-8"),
76 },
77 )
78 response_body = await communicator.receive_output()
79 self.assertEqual(response_body["type"], "http.response.body")
80 self.assertEqual(response_body["body"], b"Hello World!")
81 # Allow response.close() to finish.
82 await communicator.wait()
83
84 async def test_asgi_cookies(self):
85 application = get_asgi_application()

Callers

nothing calls this directly

Calls 2

get_asgi_applicationFunction · 0.90
_base_scopeMethod · 0.80

Tested by

no test coverage detected