(test_client_factory: TestClientFactory)
| 80 | |
| 81 | |
| 82 | def test_request_body(test_client_factory: TestClientFactory) -> None: |
| 83 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 84 | request = Request(scope, receive) |
| 85 | body = await request.body() |
| 86 | response = JSONResponse({"body": body.decode()}) |
| 87 | await response(scope, receive, send) |
| 88 | |
| 89 | client = test_client_factory(app) |
| 90 | |
| 91 | response = client.get("/") |
| 92 | assert response.json() == {"body": ""} |
| 93 | |
| 94 | response = client.post("/", json={"a": "123"}) |
| 95 | assert response.json() == {"body": '{"a":"123"}'} |
| 96 | |
| 97 | response = client.post("/", data="abc") # type: ignore |
| 98 | assert response.json() == {"body": "abc"} |
| 99 | |
| 100 | |
| 101 | def test_request_stream(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected