mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
rel=alternate JSON for queries and database pages, closes #1620
This commit is contained in:
parent
3ef47a0896
commit
b72b2423c7
7 changed files with 91 additions and 31 deletions
|
|
@ -1069,31 +1069,3 @@ def test_table_page_title(app_client, path, expected):
|
|||
response = app_client.get(path)
|
||||
title = Soup(response.text, "html.parser").find("title").text
|
||||
assert title == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path,expected",
|
||||
(
|
||||
(
|
||||
"/fixtures/table%2Fwith%2Fslashes.csv",
|
||||
"http://localhost/fixtures/table%2Fwith%2Fslashes.csv?_format=json",
|
||||
),
|
||||
("/fixtures/facetable", "http://localhost/fixtures/facetable.json"),
|
||||
(
|
||||
"/fixtures/no_primary_key/1",
|
||||
"http://localhost/fixtures/no_primary_key/1.json",
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_alternate_url_json(app_client, path, expected):
|
||||
response = app_client.get(path)
|
||||
link = response.headers["link"]
|
||||
assert link == '{}; rel="alternate"; type="application/json+datasette"'.format(
|
||||
expected
|
||||
)
|
||||
assert (
|
||||
'<link rel="alternate" type="application/json+datasette" href="{}">'.format(
|
||||
expected
|
||||
)
|
||||
in response.text
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue