mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Port Datasette from Sanic to ASGI + Uvicorn (#518)
Datasette now uses ASGI internally, and no longer depends on Sanic. It now uses Uvicorn as the underlying HTTP server. This was thirteen months in the making... for full details see the issue: https://github.com/simonw/datasette/issues/272 And for a full sequence of commits plus commentary, see the pull request: https://github.com/simonw/datasette/pull/518
This commit is contained in:
parent
35429f9089
commit
ba8db9679f
19 changed files with 1510 additions and 947 deletions
|
|
@ -8,6 +8,7 @@ from .fixtures import ( # noqa
|
|||
METADATA,
|
||||
)
|
||||
import json
|
||||
import pathlib
|
||||
import pytest
|
||||
import re
|
||||
import urllib.parse
|
||||
|
|
@ -16,6 +17,7 @@ import urllib.parse
|
|||
def test_homepage(app_client_two_attached_databases):
|
||||
response = app_client_two_attached_databases.get("/")
|
||||
assert response.status == 200
|
||||
assert "text/html; charset=utf-8" == response.headers["content-type"]
|
||||
soup = Soup(response.body, "html.parser")
|
||||
assert "Datasette Fixtures" == soup.find("h1").text
|
||||
assert (
|
||||
|
|
@ -44,6 +46,29 @@ 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
|
||||
response = app_client.get("/-/static/app.css")
|
||||
assert response.status == 200
|
||||
assert "text/css" == response.headers["content-type"]
|
||||
|
||||
|
||||
def test_static_mounts():
|
||||
for client in make_app_client(
|
||||
static_mounts=[("custom-static", str(pathlib.Path(__file__).parent))]
|
||||
):
|
||||
response = client.get("/custom-static/test_html.py")
|
||||
assert response.status == 200
|
||||
response = client.get("/custom-static/not_exists.py")
|
||||
assert response.status == 404
|
||||
|
||||
|
||||
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