MCPcopy
hub / github.com/django/django / test_headers

Method test_headers

tests/asgi/tests.py:182–211  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

180 await communicator.wait()
181
182 async def test_headers(self):
183 application = get_asgi_application()
184 communicator = ApplicationCommunicator(
185 application,
186 self.async_request_factory._base_scope(
187 path="/meta/",
188 headers=[
189 [b"content-type", b"text/plain; charset=utf-8"],
190 [b"content-length", b"77"],
191 [b"referer", b"Scotland"],
192 [b"referer", b"Wales"],
193 ],
194 ),
195 )
196 await communicator.send_input({"type": "http.request"})
197 response_start = await communicator.receive_output()
198 self.assertEqual(response_start["type"], "http.response.start")
199 self.assertEqual(response_start["status"], 200)
200 self.assertEqual(
201 set(response_start["headers"]),
202 {
203 (b"Content-Length", b"19"),
204 (b"Content-Type", b"text/plain; charset=utf-8"),
205 },
206 )
207 response_body = await communicator.receive_output()
208 self.assertEqual(response_body["type"], "http.response.body")
209 self.assertEqual(response_body["body"], b"From Scotland,Wales")
210 # Allow response.close() to finish
211 await communicator.wait()
212
213 async def test_post_body(self):
214 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