(test_client_factory: TestClientFactory)
| 99 | |
| 100 | |
| 101 | def test_request_stream(test_client_factory: TestClientFactory) -> None: |
| 102 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 103 | request = Request(scope, receive) |
| 104 | body = b"" |
| 105 | async for chunk in request.stream(): |
| 106 | body += chunk |
| 107 | response = JSONResponse({"body": body.decode()}) |
| 108 | await response(scope, receive, send) |
| 109 | |
| 110 | client = test_client_factory(app) |
| 111 | |
| 112 | response = client.get("/") |
| 113 | assert response.json() == {"body": ""} |
| 114 | |
| 115 | response = client.post("/", json={"a": "123"}) |
| 116 | assert response.json() == {"body": '{"a":"123"}'} |
| 117 | |
| 118 | response = client.post("/", data="abc") # type: ignore |
| 119 | assert response.json() == {"body": "abc"} |
| 120 | |
| 121 | |
| 122 | def test_request_form_urlencoded(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected