turnstone/tests/context/test_schema.py

24 lines
711 B
Python

"""Verify the three new context tables are created by ensure_schema."""
import sqlite3
from pathlib import Path
import pytest
from app.ingest.pipeline import ensure_schema
def test_context_tables_created(tmp_path):
db = tmp_path / "t.db"
ensure_schema(db)
conn = sqlite3.connect(str(db))
tables = {r[0] for r in conn.execute(
"SELECT name FROM sqlite_master WHERE type='table'"
).fetchall()}
conn.close()
assert "context_facts" in tables
assert "context_documents" in tables
assert "context_chunks" in tables
def test_context_schema_idempotent(tmp_path):
db = tmp_path / "t.db"
ensure_schema(db)
ensure_schema(db) # second call must not raise