import pytest def test_production_never_silently_uses_sqlite(tmp_path): from app.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.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.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()