mirror of
https://github.com/simonw/datasette.git
synced 2026-06-12 20:16:56 +02:00
Add row and query JSON extras
This commit is contained in:
parent
0fa872d438
commit
4d6daa175a
9 changed files with 861 additions and 129 deletions
|
|
@ -426,6 +426,28 @@ async def test_row_foreign_key_tables(ds_client):
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_row_extras(ds_client):
|
||||
response = await ds_client.get(
|
||||
"/fixtures/simple_primary_key/1.json?_extra=database,table,primary_keys,query,request,debug,foreign_key_tables"
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["database"] == "fixtures"
|
||||
assert data["table"] == "simple_primary_key"
|
||||
assert data["primary_keys"] == ["id"]
|
||||
assert data["query"]["sql"] == 'select * from simple_primary_key where "id"=:p0'
|
||||
assert data["query"]["params"] == {"p0": "1"}
|
||||
assert data["request"]["path"] == "/fixtures/simple_primary_key/1.json"
|
||||
assert data["debug"]["url_vars"] == {
|
||||
"database": "fixtures",
|
||||
"table": "simple_primary_key",
|
||||
"pks": "1",
|
||||
"format": "json",
|
||||
}
|
||||
assert len(data["foreign_key_tables"]) == 5
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_row_extra_render_cell():
|
||||
"""Test that _extra=render_cell returns rendered HTML from render_cell plugin hook on row pages"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue