mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
ca588b6a30
commit
1c36d07dd4
6 changed files with 117 additions and 7 deletions
|
|
@ -113,6 +113,19 @@ def prepare_connection(conn):
|
|||
"select convert_units(100, 'm', 'ft');"
|
||||
return (amount * ureg(from_)).to(to_).to_tuple()[0]
|
||||
conn.create_function('convert_units', 3, convert_units)
|
||||
|
||||
|
||||
@hookimpl
|
||||
def extra_css_urls():
|
||||
return ['https://example.com/app.css']
|
||||
|
||||
|
||||
@hookimpl
|
||||
def extra_js_urls():
|
||||
return [{
|
||||
'url': 'https://example.com/app.js',
|
||||
'sri': 'SRIHASH',
|
||||
}]
|
||||
'''
|
||||
|
||||
TABLES = '''
|
||||
|
|
|
|||
|
|
@ -333,6 +333,19 @@ def test_view_html(app_client):
|
|||
assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
|
||||
|
||||
|
||||
def test_plugin_extra_css_urls(app_client):
|
||||
response = app_client.get('/', gather_request=False)
|
||||
assert b'<link rel="stylesheet" href="https://example.com/app.css">' in response.body
|
||||
|
||||
|
||||
def test_plugin_extra_js_urls(app_client):
|
||||
response = app_client.get('/', gather_request=False)
|
||||
assert (
|
||||
b'<script src="https://example.com/app.js" integrity="SRIHASH" crossorigin="anonymous"></script>'
|
||||
in response.body
|
||||
)
|
||||
|
||||
|
||||
def test_index_metadata(app_client):
|
||||
response = app_client.get('/', gather_request=False)
|
||||
assert response.status == 200
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue