Debian Codegraph @

tests/utils.py

raw
1 from datasette.utils.sqlite import sqlite3
2
3
4 def assert_footer_links(soup):
5 footer_links = soup.find("footer").find_all("a")
6 assert 4 == len(footer_links)
7 datasette_link, license_link, source_link, about_link = footer_links
8 assert "Datasette" == datasette_link.text.strip()
9 assert "tests/fixtures.py" == source_link.text.strip()
10 assert "Apache License 2.0" == license_link.text.strip()
11 assert "About Datasette" == about_link.text.strip()
12 assert "https://datasette.io/" == datasette_link["href"]
13 assert (
14 "https://github.com/simonw/datasette/blob/main/tests/fixtures.py"
15 == source_link["href"]
16 )
17 assert (
18 "https://github.com/simonw/datasette/blob/main/LICENSE" == license_link["href"]
19 )
20 assert "https://github.com/simonw/datasette" == about_link["href"]
21
22
23 def inner_html(soup):
24 html = str(soup)
25 # This includes the parent tag - so remove that
26 inner_html = html.split(">", 1)[1].rsplit("<", 1)[0]
27 return inner_html.strip()
28
29
30 def has_load_extension():
31 conn = sqlite3.connect(":memory:")
32 return hasattr(conn, "enable_load_extension")