(tmpdir: Path, test_client_factory: TestClientFactory)
| 314 | |
| 315 | |
| 316 | def test_app_mount(tmpdir: Path, test_client_factory: TestClientFactory) -> None: |
| 317 | path = os.path.join(tmpdir, "example.txt") |
| 318 | with open(path, "w") as file: |
| 319 | file.write("<file content>") |
| 320 | |
| 321 | app = Starlette( |
| 322 | routes=[ |
| 323 | Mount("/static", StaticFiles(directory=tmpdir)), |
| 324 | ] |
| 325 | ) |
| 326 | |
| 327 | client = test_client_factory(app) |
| 328 | |
| 329 | response = client.get("/static/example.txt") |
| 330 | assert response.status_code == 200 |
| 331 | assert response.text == "<file content>" |
| 332 | |
| 333 | response = client.post("/static/example.txt") |
| 334 | assert response.status_code == 405 |
| 335 | assert response.text == "Method Not Allowed" |
| 336 | |
| 337 | |
| 338 | def test_app_debug(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected