mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
database_actions() plugin hook, closes #1077
This commit is contained in:
parent
b61f6cceb5
commit
7b19492070
10 changed files with 97 additions and 8 deletions
|
|
@ -788,7 +788,7 @@ def test_hook_menu_links(app_client):
|
|||
def test_hook_table_actions(app_client, table_or_view):
|
||||
def get_table_actions_links(html):
|
||||
soup = Soup(html, "html.parser")
|
||||
details = soup.find("details", {"class": "table-menu-links"})
|
||||
details = soup.find("details", {"class": "actions-menu-links"})
|
||||
if details is None:
|
||||
return []
|
||||
return [{"label": a.text, "href": a["href"]} for a in details.select("a")]
|
||||
|
|
@ -802,3 +802,20 @@ def test_hook_table_actions(app_client, table_or_view):
|
|||
{"label": "Database: fixtures", "href": "/"},
|
||||
{"label": "Table: {}".format(table_or_view), "href": "/"},
|
||||
]
|
||||
|
||||
|
||||
def test_hook_database_actions(app_client):
|
||||
def get_table_actions_links(html):
|
||||
soup = Soup(html, "html.parser")
|
||||
details = soup.find("details", {"class": "actions-menu-links"})
|
||||
if details is None:
|
||||
return []
|
||||
return [{"label": a.text, "href": a["href"]} for a in details.select("a")]
|
||||
|
||||
response = app_client.get("/fixtures")
|
||||
assert get_table_actions_links(response.text) == []
|
||||
|
||||
response_2 = app_client.get("/fixtures?_bot=1")
|
||||
assert get_table_actions_links(response_2.text) == [
|
||||
{"label": "Database: fixtures", "href": "/"},
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue