style: drop redundant comments and apply formatting
Frontend now uses double quotes and semicolons. No behaviour change.
This commit is contained in:
@@ -13,7 +13,7 @@ TEST_DATABASE = "books_test"
|
||||
|
||||
def _ensure_test_database() -> None:
|
||||
conn = psycopg2.connect(ADMIN_URL)
|
||||
conn.autocommit = True # CREATE DATABASE cannot run inside a transaction
|
||||
conn.autocommit = True
|
||||
try:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
@@ -28,6 +28,5 @@ def _ensure_test_database() -> None:
|
||||
|
||||
|
||||
_ensure_test_database()
|
||||
# Assigned, never defaulted: tests TRUNCATE tables, so they must not inherit a real DATABASE_URL.
|
||||
os.environ["DATABASE_URL"] = ADMIN_URL.rsplit("/", 1)[0] + "/" + TEST_DATABASE
|
||||
os.environ["PASSWORD_PEPPER"] = "test-pepper-0123456789abcdef0123456789abcdef"
|
||||
|
||||
@@ -5,7 +5,7 @@ import psycopg2
|
||||
|
||||
from app import app
|
||||
|
||||
HTTPS = "https://localhost" # the session cookie is Secure
|
||||
HTTPS = "https://localhost"
|
||||
|
||||
|
||||
def db_execute(sql: str, params: tuple = ()) -> list[tuple]:
|
||||
|
||||
@@ -70,7 +70,7 @@ class AuthTests(ApiTestCase):
|
||||
|
||||
def test_login_is_case_insensitive_on_username(self):
|
||||
self.register("Alice")
|
||||
self.client = app.test_client() # fresh cookie jar: signed out
|
||||
self.client = app.test_client()
|
||||
response = self.call(
|
||||
"POST",
|
||||
"/api/auth/login",
|
||||
@@ -116,9 +116,7 @@ class AuthTests(ApiTestCase):
|
||||
self.register()
|
||||
token = self.session_token()
|
||||
self.assertEqual(self.call("POST", "/api/auth/logout").status_code, 204)
|
||||
self.client.set_cookie(
|
||||
"sid", token, domain="localhost", path="/api"
|
||||
) # replay the stolen cookie
|
||||
self.client.set_cookie("sid", token, domain="localhost", path="/api")
|
||||
self.assertEqual(self.call("GET", "/api/auth/me").status_code, 401)
|
||||
|
||||
def test_idle_session_expires(self):
|
||||
|
||||
@@ -17,7 +17,7 @@ class BookTests(ApiTestCase):
|
||||
(book["current_page"], book["total_pages"], book["status"]),
|
||||
(0, 412, "not_started"),
|
||||
)
|
||||
self.assertIn("T", book["created_at"]) # ISO 8601
|
||||
self.assertIn("T", book["created_at"])
|
||||
|
||||
def test_create_trims_text(self):
|
||||
book = self.create_book(title=" Dune ")
|
||||
|
||||
@@ -24,12 +24,10 @@ class SearchTests(ApiTestCase):
|
||||
self.assertEqual(self.titles("q=tolkien"), ["The Hobbit"])
|
||||
|
||||
def test_wildcards_match_literally(self):
|
||||
self.assertEqual(self.titles("q=100%25"), ["100% Pure"]) # %25 is "%"
|
||||
self.assertEqual(self.titles("q=e_D"), ["100% Pure"]) # literal "_" in Jane_Doe
|
||||
self.assertEqual(
|
||||
self.titles("q=k_s"), []
|
||||
) # unescaped "_" would match "Back\\slash"
|
||||
self.assertEqual(self.titles("q=k%5Cs"), ["1000 Pages"]) # %5C is "\"
|
||||
self.assertEqual(self.titles("q=100%25"), ["100% Pure"])
|
||||
self.assertEqual(self.titles("q=e_D"), ["100% Pure"])
|
||||
self.assertEqual(self.titles("q=k_s"), [])
|
||||
self.assertEqual(self.titles("q=k%5Cs"), ["1000 Pages"])
|
||||
|
||||
def test_genre_filter_and_combination(self):
|
||||
self.assertEqual(
|
||||
|
||||
Reference in New Issue
Block a user