mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Tooltip and commas for byte length display, closes #1712
This commit is contained in:
parent
143c105f87
commit
0bc5186b7b
3 changed files with 42 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from datasette.app import Datasette, Database
|
||||
from bs4 import BeautifulSoup as Soup
|
||||
from .fixtures import ( # noqa
|
||||
app_client,
|
||||
|
|
@ -1089,3 +1090,28 @@ def test_allow_facet_off(allow_facet):
|
|||
assert "Suggested facets" in response.text
|
||||
else:
|
||||
assert "Suggested facets" not in response.text
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"size,title,length_bytes",
|
||||
(
|
||||
(2000, ' title="2.0 KB"', "2,000"),
|
||||
(20000, ' title="19.5 KB"', "20,000"),
|
||||
(20, "", "20"),
|
||||
),
|
||||
)
|
||||
async def test_format_of_binary_links(size, title, length_bytes):
|
||||
ds = Datasette()
|
||||
db_name = "binary-links-{}".format(size)
|
||||
db = ds.add_memory_database(db_name)
|
||||
sql = "select zeroblob({}) as blob".format(size)
|
||||
await db.execute_write("create table blobs as {}".format(sql))
|
||||
response = await ds.client.get("/{}/blobs".format(db_name))
|
||||
assert response.status_code == 200
|
||||
expected = "{}><Binary: {} bytes></a>".format(title, length_bytes)
|
||||
assert expected in response.text
|
||||
# And test with arbitrary SQL query too
|
||||
sql_response = await ds.client.get("/{}".format(db_name), params={"sql": sql})
|
||||
assert sql_response.status_code == 200
|
||||
assert expected in sql_response.text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue