mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented HEAD requests, removed Sanic InvalidUsage
This commit is contained in:
parent
620f0aa4f8
commit
79950c9643
4 changed files with 15 additions and 9 deletions
|
|
@ -37,10 +37,10 @@ class TestClient:
|
|||
self.asgi_app = asgi_app
|
||||
|
||||
@async_to_sync
|
||||
async def get(self, path, allow_redirects=True, redirect_count=0):
|
||||
return await self._get(path, allow_redirects, redirect_count)
|
||||
async def get(self, path, allow_redirects=True, redirect_count=0, method="GET"):
|
||||
return await self._get(path, allow_redirects, redirect_count, method)
|
||||
|
||||
async def _get(self, path, allow_redirects=True, redirect_count=0):
|
||||
async def _get(self, path, allow_redirects=True, redirect_count=0, method="GET"):
|
||||
query_string = b""
|
||||
if "?" in path:
|
||||
path, _, query_string = path.partition("?")
|
||||
|
|
@ -50,7 +50,7 @@ class TestClient:
|
|||
{
|
||||
"type": "http",
|
||||
"http_version": "1.0",
|
||||
"method": "GET",
|
||||
"method": method,
|
||||
"path": unquote(path),
|
||||
"raw_path": path.encode("ascii"),
|
||||
"query_string": query_string,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ def test_homepage(app_client_two_attached_databases):
|
|||
] == table_links
|
||||
|
||||
|
||||
def test_http_head(app_client):
|
||||
response = app_client.get("/", method="HEAD")
|
||||
assert response.status == 200
|
||||
|
||||
|
||||
def test_static(app_client):
|
||||
response = app_client.get("/-/static/app2.css")
|
||||
assert response.status == 404
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue