cmvr-visual/backend/tests/test_schema_v7.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

42 lines
2.0 KiB
Python

from pathlib import Path
from alembic import command
from alembic.config import Config
from sqlalchemy import create_engine, text
from app.core.schema import check_schema_revision
def test_007_preserves_legacy_run_and_adds_nullable_editor_fields(tmp_path):
config = Config(str(Path(__file__).parents[1] / "alembic.ini"))
path = tmp_path / "editor.sqlite"
config.attributes["url"] = "sqlite+aiosqlite:///" + str(path)
command.upgrade(config, "006")
engine = create_engine("sqlite:///" + str(path))
try:
with engine.begin() as c:
c.execute(
text(
"INSERT INTO visual_users(id,username,display_name,password_hash,role,disabled,must_change_password,created_at) VALUES('owner','owner','Owner','unchanged','user',0,0,CURRENT_TIMESTAMP)"
)
)
c.execute(
text(
"INSERT INTO visual_drafts(id,owner_id,name,kind,spec,revision,version,created_at,updated_at) VALUES('draft','owner','Legacy','three_shot','{}',1,1,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)"
)
)
c.execute(
text(
"INSERT INTO visual_workflow_runs(id,owner_id,draft_id,draft_revision,spec_snapshot,spec_hash,execution_mode,state,desired_state,hold_reasons,version,created_at) VALUES('run','owner','draft',1,'{}','hash','interactive','succeeded','run','[]',1,CURRENT_TIMESTAMP)"
)
)
command.upgrade(config, "007")
command.upgrade(config, "head")
with engine.begin() as c:
check_schema_revision(c, {"007"})
assert c.execute(
text("SELECT run_kind,output_goal,result_manifest FROM visual_workflow_runs")
).one() == ("legacy", "film", None)
assert c.scalar(text("SELECT editor_manifest FROM visual_drafts")) is None
assert c.scalar(text("SELECT password_hash FROM visual_users")) == "unchanged"
finally:
engine.dispose()