MCPcopy
hub / github.com/encode/starlette / test_request_json

Function test_request_json

tests/test_requests.py:183–192  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

181
182
183def test_request_json(test_client_factory: TestClientFactory) -> None:
184 async def app(scope: Scope, receive: Receive, send: Send) -> None:
185 request = Request(scope, receive)
186 data = await request.json()
187 response = JSONResponse({"json": data})
188 await response(scope, receive, send)
189
190 client = test_client_factory(app)
191 response = client.post("/", json={"a": "123"})
192 assert response.json() == {"json": {"a": "123"}}
193
194
195def test_request_scope_interface() -> None:

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
postMethod · 0.45

Tested by

no test coverage detected