cmvr-visual/backend/tests/test_core.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

52 lines
1.9 KiB
Python

import pytest
def test_production_never_silently_uses_sqlite(tmp_path):
from app.core.config import Settings
with pytest.raises(ValueError):
Settings(
mode="production", database_url="sqlite+aiosqlite:///:memory:", workspace_root=tmp_path
)
def test_mysql_url_preserves_hyphen_database_and_password_special_characters(tmp_path):
from app.core.config import Settings
settings = Settings(
mode="production", mysql_user="visual", mysql_password="p@ss:/?#&", workspace_root=tmp_path
)
assert settings.sqlalchemy_url.database == "cmvr-visual"
assert settings.sqlalchemy_url.password == "p@ss:/?#&"
assert settings.sqlalchemy_url.drivername == "mysql+aiomysql"
async def test_application_creates_only_prefixed_tables(system):
from sqlalchemy import inspect
async with system.app.state.db.engine.connect() as connection:
names = await connection.run_sync(lambda sync: inspect(sync).get_table_names())
assert names and all(name.startswith("visual_") for name in names)
async def test_status_discloses_preview_mode_without_connection_details(system):
response = await system.client.get("/api/system/status")
assert response.status_code == 200
status = response.json()
assert status["environment"] == "test" and status["database_backend"] == "sqlite"
assert "database_url" not in response.text and "password" not in response.text
async def test_only_one_coordinator_can_hold_the_workspace_lock(system):
from app.services.orchestration.coordinator import Coordinator
from filelock import Timeout
first = Coordinator(system.settings, system.app.state.db, system.provider)
second = Coordinator(system.settings, system.app.state.db, system.provider)
try:
await first.start()
with pytest.raises(Timeout):
await second.start()
finally:
await first.close()