If Request is instantiated without the receive channel, then .body() is not available.
(
test_client_factory: TestClientFactory,
)
| 217 | |
| 218 | |
| 219 | def test_request_without_setting_receive( |
| 220 | test_client_factory: TestClientFactory, |
| 221 | ) -> None: |
| 222 | """ |
| 223 | If Request is instantiated without the receive channel, then .body() |
| 224 | is not available. |
| 225 | """ |
| 226 | |
| 227 | async def app(scope: Scope, receive: Receive, send: Send) -> None: |
| 228 | request = Request(scope) |
| 229 | try: |
| 230 | data = await request.json() |
| 231 | except RuntimeError: |
| 232 | data = "Receive channel not available" |
| 233 | response = JSONResponse({"json": data}) |
| 234 | await response(scope, receive, send) |
| 235 | |
| 236 | client = test_client_factory(app) |
| 237 | response = client.post("/", json={"a": "123"}) |
| 238 | assert response.json() == {"json": "Receive channel not available"} |
| 239 | |
| 240 | |
| 241 | def test_request_disconnect( |
nothing calls this directly
no test coverage detected