(tmp_path: Path, test_client_factory: TestClientFactory)
| 348 | |
| 349 | |
| 350 | def test_file_response_with_range_header(tmp_path: Path, test_client_factory: TestClientFactory) -> None: |
| 351 | content = b"file content" |
| 352 | filename = "hello.txt" |
| 353 | path = tmp_path / filename |
| 354 | path.write_bytes(content) |
| 355 | etag = '"a_non_autogenerated_etag"' |
| 356 | app = FileResponse(path=path, filename=filename, headers={"etag": etag}) |
| 357 | client = test_client_factory(app) |
| 358 | response = client.get("/", headers={"range": "bytes=0-4", "if-range": etag}) |
| 359 | assert response.status_code == status.HTTP_206_PARTIAL_CONTENT |
| 360 | assert response.content == content[:5] |
| 361 | assert response.headers["etag"] == etag |
| 362 | assert response.headers["content-length"] == "5" |
| 363 | assert response.headers["content-range"] == f"bytes 0-4/{len(content)}" |
| 364 | |
| 365 | |
| 366 | @pytest.mark.anyio |
nothing calls this directly
no test coverage detected