mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
/-/ alternative URL for homepage, closes #2393
This commit is contained in:
parent
bf953628bb
commit
93067668fe
5 changed files with 33 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from bs4 import BeautifulSoup as Soup
|
||||
from datasette.app import Datasette
|
||||
from datasette.utils import allowed_pragmas
|
||||
from .fixtures import ( # noqa
|
||||
app_client,
|
||||
|
|
@ -51,6 +52,27 @@ def test_homepage(app_client_two_attached_databases):
|
|||
] == table_links
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("path", ("/", "/-/"))
|
||||
async def test_homepage_alternative_location(path, tmp_path_factory):
|
||||
template_dir = tmp_path_factory.mktemp("templates")
|
||||
(template_dir / "index.html").write_text("Custom homepage", "utf-8")
|
||||
datasette = Datasette(template_dir=str(template_dir))
|
||||
response = await datasette.client.get(path)
|
||||
assert response.status_code == 200
|
||||
html = response.text
|
||||
if path == "/":
|
||||
assert html == "Custom homepage"
|
||||
else:
|
||||
assert '<meta name="robots" content="noindex">' in html
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_homepage_alternative_redirect(ds_client):
|
||||
response = await ds_client.get("/-")
|
||||
assert response.status_code == 301
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_http_head(ds_client):
|
||||
response = await ds_client.head("/")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue