style: format backend with black
Also drops the session-sliding comment in login_required.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user