mirror of
https://github.com/simonw/datasette.git
synced 2026-09-27 12:24:07 +02:00
Show correct query timings, closes #2446
This commit is contained in:
parent
ffd3b8cada
commit
9cdf95ac2c
2 changed files with 20 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import pathlib
|
||||
import urllib.parse
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup as Soup
|
||||
|
|
@ -72,6 +73,21 @@ DEFAULT_EXPRESSION_OPTIONS = [
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("table", ("simple_primary_key", "simple_view"))
|
||||
@pytest.mark.parametrize("duration", (0.125, 0.25))
|
||||
async def test_table_footer_query_ms(ds_client, monkeypatch, table, duration):
|
||||
times = iter((10.0, 10.0 + duration))
|
||||
# Only mock the table view's clock, leaving SQL time limits unaffected.
|
||||
monkeypatch.setattr(
|
||||
"datasette.views.table.time", SimpleNamespace(perf_counter=lambda: next(times))
|
||||
)
|
||||
response = await ds_client.get(f"/fixtures/{table}")
|
||||
assert response.status_code == 200
|
||||
footer = Soup(response.text, "html.parser").find("footer")
|
||||
assert f"Queries took {duration * 1000}ms" in footer.get_text()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"path,expected_definition_sql",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue