mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Moved plugin HTML tests from test_html to test_plugins
This commit is contained in:
parent
27c10f6482
commit
98c8f0e728
2 changed files with 25 additions and 13 deletions
|
|
@ -416,19 +416,6 @@ def test_view_html(app_client):
|
||||||
assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
|
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):
|
def test_index_metadata(app_client):
|
||||||
response = app_client.get('/', gather_request=False)
|
response = app_client.get('/', gather_request=False)
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,31 @@ def test_plugins_dir_plugin(app_client):
|
||||||
assert pytest.approx(328.0839) == response.json['rows'][0][0]
|
assert pytest.approx(328.0839) == response.json['rows'][0][0]
|
||||||
|
|
||||||
|
|
||||||
|
def test_plugin_extra_css_urls(app_client):
|
||||||
|
response = app_client.get('/', gather_request=False)
|
||||||
|
links = Soup(response.body, 'html.parser').findAll('link')
|
||||||
|
assert [
|
||||||
|
l for l in links
|
||||||
|
if l.attrs == {
|
||||||
|
'rel': ['stylesheet'],
|
||||||
|
'href': 'https://example.com/app.css'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_plugin_extra_js_urls(app_client):
|
||||||
|
response = app_client.get('/', gather_request=False)
|
||||||
|
scripts = Soup(response.body, 'html.parser').findAll('script')
|
||||||
|
assert [
|
||||||
|
s for s in scripts
|
||||||
|
if s.attrs == {
|
||||||
|
'integrity': 'SRIHASH',
|
||||||
|
'crossorigin': 'anonymous',
|
||||||
|
'src': 'https://example.com/jquery.js'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_plugins_with_duplicate_js_urls(app_client):
|
def test_plugins_with_duplicate_js_urls(app_client):
|
||||||
# If two plugins both require jQuery, jQuery should be loaded only once
|
# If two plugins both require jQuery, jQuery should be loaded only once
|
||||||
response = app_client.get(
|
response = app_client.get(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue