Mirror test layout, domcontentloaded waits, backup DB writes outside threads
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
@@ -0,0 +1,27 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
import sqlite3
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import TEST_DATA_DIR
|
||||
|
||||
QUERIES = [
|
||||
("idx_posts_published", "SELECT * FROM posts WHERE topic = 'rol' AND status = 'published' AND deleted_at IS NULL ORDER BY published_at DESC LIMIT 25"),
|
||||
("idx_posts_slug", "SELECT * FROM posts WHERE slug = 'x'"),
|
||||
("idx_sessions_token", "SELECT * FROM sessions WHERE token = 'x'"),
|
||||
("idx_users_api_key", "SELECT * FROM users WHERE api_key = 'x'"),
|
||||
("idx_media_items_kind", "SELECT * FROM media_items WHERE kind = 'flyer' AND deleted_at IS NULL ORDER BY position, id"),
|
||||
("idx_notifications_user", "SELECT * FROM notifications WHERE user_uid = 'x' ORDER BY created_at DESC LIMIT 50"),
|
||||
("idx_audit_log_created", "SELECT uid FROM audit_log WHERE created_at < '2020-01-01'"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("index,sql", QUERIES, ids=[item[0] for item in QUERIES])
|
||||
def test_index_is_used_without_temp_btree(app_server, index, sql):
|
||||
connection = sqlite3.connect(TEST_DATA_DIR / "molodetz.db")
|
||||
try:
|
||||
plan = " | ".join(row[-1] for row in connection.execute(f"EXPLAIN QUERY PLAN {sql}"))
|
||||
finally:
|
||||
connection.close()
|
||||
assert f"USING INDEX {index}" in plan or f"USING COVERING INDEX {index}" in plan, plan
|
||||
assert "TEMP B-TREE" not in plan, plan
|
||||
@@ -0,0 +1,7 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
from molodetz.database.sql_lint import collect_sql, lint
|
||||
|
||||
|
||||
def test_raw_sql_parses_with_sqlglot():
|
||||
assert collect_sql(), "expected raw SQL literals to lint"
|
||||
assert lint() == []
|
||||
Reference in New Issue
Block a user