Moved plugin HTML tests from test_html to test_plugins

pull/379/head
Simon Willison 2018-05-28 14:23:48 -07:00
rodzic 27c10f6482
commit 98c8f0e728
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 17E2DEA2588B7F52
2 zmienionych plików z 25 dodań i 13 usunięć

Wyświetl plik

@ -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')]
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

Wyświetl plik

@ -15,6 +15,31 @@ def test_plugins_dir_plugin(app_client):
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):
# If two plugins both require jQuery, jQuery should be loaded only once
response = app_client.get(