mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
/-/databases and homepage maintain connection order, closes #1216
This commit is contained in:
parent
03b35d70e2
commit
807de378d0
4 changed files with 7 additions and 6 deletions
|
|
@ -646,7 +646,7 @@ class Datasette:
|
||||||
"is_memory": d.is_memory,
|
"is_memory": d.is_memory,
|
||||||
"hash": d.hash,
|
"hash": d.hash,
|
||||||
}
|
}
|
||||||
for name, d in sorted(self.databases.items(), key=lambda p: p[1].name)
|
for name, d in self.databases.items()
|
||||||
if name != "_internal"
|
if name != "_internal"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,8 @@ def make_app_client(
|
||||||
for extra_filename, extra_sql in extra_databases.items():
|
for extra_filename, extra_sql in extra_databases.items():
|
||||||
extra_filepath = os.path.join(tmpdir, extra_filename)
|
extra_filepath = os.path.join(tmpdir, extra_filename)
|
||||||
sqlite3.connect(extra_filepath).executescript(extra_sql)
|
sqlite3.connect(extra_filepath).executescript(extra_sql)
|
||||||
files.append(extra_filepath)
|
# Insert at start to help test /-/databases ordering:
|
||||||
|
files.insert(0, extra_filepath)
|
||||||
os.chdir(os.path.dirname(filepath))
|
os.chdir(os.path.dirname(filepath))
|
||||||
config = config or {}
|
config = config or {}
|
||||||
for key, value in {
|
for key, value in {
|
||||||
|
|
|
||||||
|
|
@ -1918,7 +1918,7 @@ def test_database_with_space_in_name(app_client_two_attached_databases, path):
|
||||||
|
|
||||||
def test_common_prefix_database_names(app_client_conflicting_database_names):
|
def test_common_prefix_database_names(app_client_conflicting_database_names):
|
||||||
# https://github.com/simonw/datasette/issues/597
|
# https://github.com/simonw/datasette/issues/597
|
||||||
assert ["fixtures", "foo", "foo-bar"] == [
|
assert ["foo-bar", "foo", "fixtures"] == [
|
||||||
d["name"]
|
d["name"]
|
||||||
for d in app_client_conflicting_database_names.get("/-/databases.json").json
|
for d in app_client_conflicting_database_names.get("/-/databases.json").json
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ def test_homepage(app_client_two_attached_databases):
|
||||||
)
|
)
|
||||||
# Should be two attached databases
|
# Should be two attached databases
|
||||||
assert [
|
assert [
|
||||||
{"href": "/fixtures", "text": "fixtures"},
|
|
||||||
{"href": r"/extra%20database", "text": "extra database"},
|
{"href": r"/extra%20database", "text": "extra database"},
|
||||||
|
{"href": "/fixtures", "text": "fixtures"},
|
||||||
] == [{"href": a["href"], "text": a.text.strip()} for a in soup.select("h2 a")]
|
] == [{"href": a["href"], "text": a.text.strip()} for a in soup.select("h2 a")]
|
||||||
# The first attached database should show count text and attached tables
|
# Database should show count text and attached tables
|
||||||
h2 = soup.select("h2")[1]
|
h2 = soup.select("h2")[0]
|
||||||
assert "extra database" == h2.text.strip()
|
assert "extra database" == h2.text.strip()
|
||||||
counts_p, links_p = h2.find_all_next("p")[:2]
|
counts_p, links_p = h2.find_all_next("p")[:2]
|
||||||
assert (
|
assert (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue