28 lines
870 B
Python
28 lines
870 B
Python
from pathlib import Path
|
|
|
|
from sqlmodel import SQLModel
|
|
|
|
from backend.app.db.session import create_app_engine
|
|
|
|
|
|
def test_sqlite_engine_waits_for_busy_database_and_uses_wal(tmp_path):
|
|
db_path = tmp_path / "runtime.db"
|
|
engine = create_app_engine(Path(db_path))
|
|
SQLModel.metadata.create_all(engine)
|
|
|
|
with engine.connect() as connection:
|
|
busy_timeout = connection.exec_driver_sql("PRAGMA busy_timeout").scalar_one()
|
|
journal_mode = str(connection.exec_driver_sql("PRAGMA journal_mode").scalar_one()).lower()
|
|
|
|
assert int(busy_timeout) >= 30000
|
|
assert journal_mode == "wal"
|
|
|
|
|
|
def test_sqlite_engine_allows_ui_request_bursts(tmp_path):
|
|
db_path = tmp_path / "runtime.db"
|
|
engine = create_app_engine(Path(db_path))
|
|
|
|
assert engine.pool.size() >= 20
|
|
assert engine.pool._max_overflow >= 20
|
|
assert engine.pool._timeout <= 10
|