mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Use aiofiles for static, refs #272
This commit is contained in:
parent
ca03940f6d
commit
8a1a15d725
4 changed files with 50 additions and 12 deletions
|
|
@ -52,7 +52,9 @@ class TestClient:
|
|||
)
|
||||
await instance.send_input({"type": "http.request"})
|
||||
# First message back should be response.start with headers and status
|
||||
messages = []
|
||||
start = await instance.receive_output(2)
|
||||
messages.append(start)
|
||||
assert start["type"] == "http.response.start"
|
||||
headers = dict(
|
||||
[(k.decode("utf8"), v.decode("utf8")) for k, v in start["headers"]]
|
||||
|
|
@ -62,6 +64,7 @@ class TestClient:
|
|||
body = b""
|
||||
while True:
|
||||
message = await instance.receive_output(2)
|
||||
messages.append(message)
|
||||
assert message["type"] == "http.response.body"
|
||||
body += message["body"]
|
||||
if not message.get("more_body"):
|
||||
|
|
|
|||
|
|
@ -44,6 +44,14 @@ def test_homepage(app_client_two_attached_databases):
|
|||
] == table_links
|
||||
|
||||
|
||||
def test_static(app_client):
|
||||
response = app_client.get("/-/static/app2.css")
|
||||
assert response.status == 404
|
||||
response = app_client.get("/-/static/app.css")
|
||||
assert response.status == 200
|
||||
assert "text/css" == response.headers["content-type"]
|
||||
|
||||
|
||||
def test_memory_database_page():
|
||||
for client in make_app_client(memory=True):
|
||||
response = client.get("/:memory:")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue