55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
from pathlib import Path
|
|
|
|
import sqlalchemy as sa
|
|
from alembic.migration import MigrationContext
|
|
from alembic.operations import Operations
|
|
|
|
|
|
def _load_migration_module():
|
|
path = (
|
|
Path(__file__).resolve().parents[1]
|
|
/ "alembic"
|
|
/ "versions"
|
|
/ "20260405_add_mounted_ai_runtime_tables.py"
|
|
)
|
|
spec = importlib.util.spec_from_file_location("mounted_ai_runtime_tables_migration", path)
|
|
module = importlib.util.module_from_spec(spec)
|
|
assert spec is not None
|
|
assert spec.loader is not None
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_mounted_ai_runtime_migration_adds_tables() -> None:
|
|
migration = _load_migration_module()
|
|
engine = sa.create_engine("sqlite:///:memory:")
|
|
|
|
with engine.begin() as conn:
|
|
context = MigrationContext.configure(conn)
|
|
migration.op = Operations(context)
|
|
migration.upgrade()
|
|
|
|
inspector = sa.inspect(conn)
|
|
tables = set(inspector.get_table_names())
|
|
|
|
assert "mounted_topic_workspaces" in tables
|
|
assert "mounted_draft_workspaces" in tables
|
|
assert "mounted_conversation_runs" in tables
|
|
assert "mounted_agent_traces" in tables
|
|
assert "mounted_tool_capability_policies" in tables
|
|
|
|
migration.downgrade()
|
|
|
|
inspector = sa.inspect(conn)
|
|
tables = set(inspector.get_table_names())
|
|
|
|
assert "mounted_topic_workspaces" not in tables
|
|
assert "mounted_draft_workspaces" not in tables
|
|
assert "mounted_conversation_runs" not in tables
|
|
assert "mounted_agent_traces" not in tables
|
|
assert "mounted_tool_capability_policies" not in tables
|
|
|