Unit tests for advanced export box HTML, closes #320

pull/349/head
Simon Willison 2018-07-23 20:38:31 -07:00
rodzic 700d83d8ad
commit 3955771fea
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 17E2DEA2588B7F52
1 zmienionych plików z 22 dodań i 0 usunięć

Wyświetl plik

@ -771,3 +771,25 @@ def test_canned_query_with_custom_metadata(app_client):
</div>""".strip()
== soup.find("div", {"class": "metadata-description"}).prettify().strip()
)
@pytest.mark.parametrize('path,has_object,has_stream,has_expand', [
("/fixtures/no_primary_key", False, True, False),
("/fixtures/complex_foreign_keys", True, False, True),
])
def test_advanced_export_box(app_client, path, has_object, has_stream, has_expand):
response = app_client.get(path)
assert response.status == 200
soup = Soup(response.body, "html.parser")
# JSON shape options
expected_json_shapes = ["default", "array"]
if has_object:
expected_json_shapes.append("object")
div = soup.find("div", {"class": "advanced-export"})
assert expected_json_shapes == [a.text for a in div.find("p").findAll("a")]
# "stream all rows" option
if has_stream:
assert "stream all rows" in str(div)
# "expand labels" option
if has_expand:
assert "expand labels" in str(div)