Better titles for canned query pages, closes #887

pull/848/head
Simon Willison 2020-07-01 17:23:37 -07:00
rodzic f1f581b7ff
commit 57879dc8b3
3 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -28,7 +28,7 @@
{% block content %}
<h1 style="padding-left: 10px; border-left: 10px solid #{{ database_color(database) }}">{{ metadata.title or database }}{% if private %} 🔒{% endif %}</h1>
<h1 style="padding-left: 10px; border-left: 10px solid #{{ database_color(database) }}">{{ metadata.title or database }}{% if canned_query and not metadata.title %}: {{ canned_query }}{% endif %}{% if private %} 🔒{% endif %}</h1>
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}

Wyświetl plik

@ -1004,6 +1004,13 @@ def test_404_content_type(app_client):
assert "text/html; charset=utf-8" == response.headers["content-type"]
def test_canned_query_default_title(app_client):
response = app_client.get("/fixtures/magic_parameters")
assert response.status == 200
soup = Soup(response.body, "html.parser")
assert "fixtures: magic_parameters" == soup.find("h1").text
def test_canned_query_with_custom_metadata(app_client):
response = app_client.get("/fixtures/neighborhood_search?text=town")
assert response.status == 200

Wyświetl plik

@ -179,13 +179,13 @@ def test_view_query(allow, expected_anon, expected_auth):
assert expected_anon == anon_response.status
if allow and anon_response.status == 200:
# Should be no padlock
assert ">fixtures 🔒</h1>" not in anon_response.text
assert "🔒</h1>" not in anon_response.text
auth_response = client.get(
"/fixtures/q", cookies={"ds_actor": client.actor_cookie({"id": "root"})}
)
assert expected_auth == auth_response.status
if allow and expected_anon == 403 and expected_auth == 200:
assert ">fixtures 🔒</h1>" in auth_response.text
assert ">fixtures: q 🔒</h1>" in auth_response.text
@pytest.mark.parametrize(