style: format backend with black

Also drops the session-sliding comment in login_required.
This commit is contained in:
2026-10-02 14:46:16 -05:00
parent 2512c67893
commit 63c9991421
14 changed files with 320 additions and 82 deletions
+10 -3
View File
@@ -1,10 +1,13 @@
"""Point the app at a dedicated test database before any test module imports it."""
import os
import psycopg2
from psycopg2 import sql
ADMIN_URL = os.environ.get("TEST_ADMIN_DATABASE_URL", "postgresql://postgres:[email protected]:5432/postgres")
ADMIN_URL = os.environ.get(
"TEST_ADMIN_DATABASE_URL", "postgresql://postgres:[email protected]:5432/postgres"
)
TEST_DATABASE = "books_test"
@@ -13,9 +16,13 @@ def _ensure_test_database() -> None:
conn.autocommit = True # CREATE DATABASE cannot run inside a transaction
try:
with conn.cursor() as cur:
cur.execute("SELECT 1 FROM pg_database WHERE datname = %s", (TEST_DATABASE,))
cur.execute(
"SELECT 1 FROM pg_database WHERE datname = %s", (TEST_DATABASE,)
)
if cur.fetchone() is None:
cur.execute(sql.SQL("CREATE DATABASE {}").format(sql.Identifier(TEST_DATABASE)))
cur.execute(
sql.SQL("CREATE DATABASE {}").format(sql.Identifier(TEST_DATABASE))
)
finally:
conn.close()