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

Function test_request_json

tests/test_requests.py:183–192  ·  tests/test_requests.py::test_request_json
(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({class="st">"json": data})
188 await response(scope, receive, send)
189
190 client = test_client_factory(app)
191 response = client.post(class="st">"/", json={class="st">"a": class="st">"123"})
192 assert response.json() == {class="st">"json": {class="st">"a": class="st">"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