Remove hashed URL mode

Also simplified how view class routing works.

Refs #1661
This commit is contained in:
Simon Willison 2022-03-18 17:12:03 -07:00 committed by GitHub
commit d4f60c2388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 79 additions and 266 deletions

View file

@ -1,6 +1,5 @@
from datasette.app import Datasette
from datasette.utils import PrefixedUrlString
from .fixtures import app_client_with_hash
import pytest
@ -147,20 +146,3 @@ def test_row(ds, base_url, format, expected):
actual = ds.urls.row("_memory", "facetable", "1", format=format)
assert actual == expected
assert isinstance(actual, PrefixedUrlString)
@pytest.mark.parametrize("base_url", ["/", "/prefix/"])
def test_database_hashed(app_client_with_hash, base_url):
ds = app_client_with_hash.ds
original_base_url = ds._settings["base_url"]
try:
ds._settings["base_url"] = base_url
db_hash = ds.get_database("fixtures").hash
assert len(db_hash) == 64
expected = f"{base_url}fixtures-{db_hash[:7]}"
assert ds.urls.database("fixtures") == expected
assert ds.urls.table("fixtures", "name") == expected + "/name"
assert ds.urls.query("fixtures", "name") == expected + "/name"
finally:
# Reset this since fixture is shared with other tests
ds._settings["base_url"] = original_base_url