get_asgi_application() returns a functioning ASGI callable.
(self)
| 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() |
nothing calls this directly
no test coverage detected