Include views on homepage, fix table counts

If we have less than 5 tables we now also show one or more views in the
summary on the homepage.

Also corrected the logic for the row counts - we now count hidden and
visible tables separately.

Closes #373, Refs #460
This commit is contained in:
Simon Willison 2019-05-15 17:28:07 -07:00
commit 5d6b2c30f1
5 changed files with 42 additions and 24 deletions

View file

@ -32,16 +32,17 @@ def test_homepage(app_client_two_attached_databases):
h2 = soup.select("h2")[1]
assert "extra_database" == h2.text.strip()
counts_p, links_p = h2.find_all_next("p")
assert "7 rows in 5 tables, 5 rows in 4 hidden tables" == counts_p.text.strip().replace(
" ", ""
).replace(
"\n", ""
assert (
"7 rows in 1 table, 5 rows in 4 hidden tables, 1 view" == counts_p.text.strip()
)
# We should only show visible, not hidden tables here:
table_links = [
{"href": a["href"], "text": a.text.strip()} for a in links_p.findAll("a")
]
assert [{"href": "/extra_database/searchable", "text": "searchable"}] == table_links
assert [
{"href": "/extra_database/searchable", "text": "searchable"},
{"href": "/extra_database/searchable_view", "text": "searchable_view"},
] == table_links
def test_memory_database_page(app_client_with_memory):