Default 405 for POST, plus tests

pull/1368/head
Simon Willison 2021-06-23 15:27:30 -07:00
rodzic 3a50015566
commit 4a3e8561ab
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -106,6 +106,9 @@ class BaseView:
async def options(self, request, *args, **kwargs):
return Response.text("Method not allowed", status=405)
async def post(self, request, *args, **kwargs):
return Response.text("Method not allowed", status=405)
async def put(self, request, *args, **kwargs):
return Response.text("Method not allowed", status=405)

Wyświetl plik

@ -92,6 +92,13 @@ def test_memory_database_page():
assert response.status == 200
def test_not_allowed_methods():
with make_app_client(memory=True) as client:
for method in ("post", "put", "patch", "delete"):
response = client.request(path="/_memory", method=method.upper())
assert response.status == 405
def test_database_page_redirects_with_url_hash(app_client_with_hash):
response = app_client_with_hash.get("/fixtures", allow_redirects=False)
assert response.status == 302