052f019075
SQLite database layer with thread-local connections, WAL journal mode, foreign key enforcement, and FTS5 full-text search on utterances via content-table triggers. TDD: 5 tests written first, all passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
986 B
Python
40 lines
986 B
Python
import pytest
|
|
import os
|
|
from app.shared.config import Settings
|
|
from app.shared.database import init_schema, get_db
|
|
|
|
|
|
@pytest.fixture
|
|
def settings(tmp_path):
|
|
db_file = str(tmp_path / "test.db")
|
|
clips_dir = str(tmp_path / "clips")
|
|
os.makedirs(clips_dir, exist_ok=True)
|
|
s = Settings(
|
|
db_path=db_file,
|
|
clips_dir=clips_dir,
|
|
speaches_url="http://localhost:9999",
|
|
ollama_url="http://localhost:9999",
|
|
livekit_api_key="test",
|
|
livekit_api_secret="test",
|
|
)
|
|
init_schema(s)
|
|
return s
|
|
|
|
|
|
@pytest.fixture
|
|
def db(settings):
|
|
return get_db(settings)
|
|
|
|
|
|
# Add to conftest.py
|
|
from app.shared import database as _db_module
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def reset_db_connection():
|
|
"""Reset thread-local DB connection between tests."""
|
|
_db_module._local.conn = None
|
|
yield
|
|
if hasattr(_db_module._local, 'conn') and _db_module._local.conn:
|
|
_db_module._local.conn.close()
|
|
_db_module._local.conn = None
|