mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
909e66dfdb
commit
21b57cdf9a
3 changed files with 18 additions and 2 deletions
|
|
@ -31,6 +31,7 @@ def make_app_client(
|
|||
filename="fixtures.db",
|
||||
is_immutable=False,
|
||||
extra_databases=None,
|
||||
inspect_data=None,
|
||||
):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
filepath = os.path.join(tmpdir, filename)
|
||||
|
|
@ -71,6 +72,7 @@ def make_app_client(
|
|||
metadata=METADATA,
|
||||
plugins_dir=plugins_dir,
|
||||
config=config,
|
||||
inspect_data=inspect_data,
|
||||
)
|
||||
ds.sqlite_functions.append(("sleep", 1, lambda n: time.sleep(float(n))))
|
||||
client = TestClient(ds.app().test_client)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from .fixtures import app_client
|
||||
from .fixtures import app_client, make_app_client
|
||||
from datasette.cli import cli
|
||||
from click.testing import CliRunner
|
||||
import pathlib
|
||||
|
|
@ -31,6 +31,14 @@ def test_inspect_cli_writes_to_file(app_client):
|
|||
assert ["fixtures"] == list(data.keys())
|
||||
|
||||
|
||||
def test_serve_with_inspect_file_prepopulates_table_counts_cache():
|
||||
inspect_data = {"fixtures": {"tables": {"hithere": {"count": 44}}}}
|
||||
for client in make_app_client(inspect_data=inspect_data, is_immutable=True):
|
||||
assert inspect_data == client.ds.inspect_data
|
||||
db = client.ds.databases["fixtures"]
|
||||
assert {"hithere": 44} == db.cached_table_counts
|
||||
|
||||
|
||||
def test_spatialite_error_if_attempt_to_open_spatialite():
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue