.resolve_db_name() and .execute() work without inspect

Refs #420
This commit is contained in:
Simon Willison 2019-03-31 16:51:52 -07:00
commit 7d0f668556
4 changed files with 68 additions and 16 deletions

View file

@ -29,6 +29,7 @@ def make_app_client(
cors=False,
config=None,
filename="fixtures.db",
is_immutable=False,
):
with tempfile.TemporaryDirectory() as tmpdir:
filepath = os.path.join(tmpdir, filename)
@ -48,7 +49,8 @@ def make_app_client(
}
)
ds = Datasette(
[filepath],
[] if is_immutable else [filepath],
immutables=[filepath] if is_immutable else [],
cors=cors,
metadata=METADATA,
plugins_dir=plugins_dir,
@ -76,8 +78,8 @@ def app_client_no_files():
@pytest.fixture(scope="session")
def app_client_with_hash():
yield from make_app_client(config={
'hash_urls': True
})
'hash_urls': True,
}, is_immutable=True)
@pytest.fixture(scope='session')

View file

@ -1317,10 +1317,10 @@ def test_ttl_parameter(app_client, path, expected_cache_control):
("/fixtures/facetable.json?_hash=1", "/fixtures-HASH/facetable.json"),
("/fixtures/facetable.json?city_id=1&_hash=1", "/fixtures-HASH/facetable.json?city_id=1"),
])
def test_hash_parameter(app_client, path, expected_redirect):
def test_hash_parameter(app_client_with_hash, path, expected_redirect):
# First get the current hash for the fixtures database
current_hash = app_client.get("/-/inspect.json").json["fixtures"]["hash"][:7]
response = app_client.get(path, allow_redirects=False)
current_hash = app_client_with_hash.get("/-/inspect.json").json["fixtures"]["hash"][:7]
response = app_client_with_hash.get(path, allow_redirects=False)
assert response.status == 302
location = response.headers["Location"]
assert expected_redirect.replace("HASH", current_hash) == location