MCPcopy
hub / github.com/encode/starlette / test_staticfiles_post

Function test_staticfiles_post

tests/test_staticfiles.py:82–93  ·  view source on GitHub ↗
(tmpdir: Path, test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

80
81
82def test_staticfiles_post(tmpdir: Path, test_client_factory: TestClientFactory) -> None:
83 path = os.path.join(tmpdir, "example.txt")
84 with open(path, "w") as file:
85 file.write("<file content>")
86
87 routes = [Mount("/", app=StaticFiles(directory=tmpdir), name="static")]
88 app = Starlette(routes=routes)
89 client = test_client_factory(app)
90
91 response = client.post("/example.txt")
92 assert response.status_code == 405
93 assert response.text == "Method Not Allowed"
94
95
96def test_staticfiles_with_directory_returns_404(tmpdir: Path, test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 6

MountClass · 0.90
StaticFilesClass · 0.90
StarletteClass · 0.90
test_client_factoryFunction · 0.85
writeMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected