Files
rag-technical-docs-assistant/tests/integration/test_migrations.py
T
11linear11 996435d2ae feat(voice): add authenticated Phase 2 live lifecycle
Add cookie authentication, owned conversations, durable Live reservations,
tool completion/replay fencing, revocation, and startup reconciliation.
Introduce forward lifecycle/owner-chain migrations and the temporary Gemini
adapter while preserving the existing OpenAI Realtime adapter.

Include the executable audio client, regression coverage, configuration,
API/database documentation, and recorded acceptance evidence.

Validation: focused review suite 82 passed; Python/TOML parsing, JavaScript
syntax, and whitespace checks passed. Full PostgreSQL/provider-free results
are recorded in the repair report; real-provider/browser acceptance is unrun.

Follow-up work remains for configurable OpenAI/Gemini selection, transport
admission, authority diagnostics, playback message bounds, and client replay
identity after ambiguous creation responses.
2026-10-09 07:59:02 -04:00

63 lines
2.8 KiB
Python

"""Alembic schema lifecycle and full embedding-profile compatibility."""
import json
import pytest
from sqlalchemy import text
from tests.support.database_rows import seed
from dataclasses import replace
from alembic import command
from app.infrastructure.database import CompatibilityError, check_compatibility
def test_empty_migration_tables_and_pinned_profile(migrated_db, settings):
engine, config = migrated_db
with engine.connect() as connection:
check_compatibility(connection, settings.embedding_profile)
tables = connection.execute(text("""
SELECT tablename FROM pg_tables WHERE schemaname=current_schema()
""")).scalars().all()
assert set(tables) == {
"alembic_version", "organizations", "users", "organization_settings",
"documents", "ingestion_jobs", "document_chunks", "audit_events",
"auth_sessions", "conversations", "live_sessions", "tool_calls",
}
for changed in (
replace(settings.embedding_profile, model="different-model"),
replace(settings.embedding_profile, dimensions=4),
replace(settings.embedding_profile, endpoint="https://other.invalid"),
replace(settings.embedding_profile, provider="other-provider"),
replace(settings.embedding_profile, preprocessing_version="v2"),
):
with pytest.raises(CompatibilityError):
check_compatibility(connection, changed)
config.attributes["ingestion_settings"] = settings.model_copy(
update={"embedding_dimensions": 4, "embedding_model": "changed"}
)
with engine.begin() as connection:
config.attributes["connection"] = connection
with pytest.raises(CompatibilityError):
command.upgrade(config, "head")
check_compatibility(connection, settings.embedding_profile)
def test_document_profile_mismatch(migrated_db, settings):
engine, _ = migrated_db
with engine.begin() as connection:
_, _, doc = seed(connection)
with pytest.raises(CompatibilityError):
check_compatibility(connection, settings.embedding_profile)
connection.execute(text("""
UPDATE documents SET processing_profile=CAST(:profile AS jsonb) WHERE id=:doc
"""), {"doc": doc, "profile": json.dumps(settings.processing_profile())})
check_compatibility(connection, settings.embedding_profile)
def test_initial_migration_round_trip(migrated_db, settings):
engine, config = migrated_db
with engine.begin() as connection:
config.attributes["connection"] = connection
command.downgrade(config, "base")
assert connection.execute(text("SELECT to_regclass('document_chunks')")).scalar_one() is None
command.upgrade(config, "head")
check_compatibility(connection, settings.embedding_profile)