"""Verify the three context tables are created by ensure_context_schema.""" import sqlite3 from pathlib import Path import pytest from app.db.schema import ensure_context_schema def test_context_tables_created(tmp_path): db = tmp_path / "t.db" ensure_context_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_context_schema(db) ensure_context_schema(db) # second call must not raise