feat: add takeover fields to Authorization model

Add takeover_enabled, takeover_mode, and takeover_delay_seconds columns
to the Authorization model with a SQLite migration, and include them
in to_dict(). Test: test_takeover_model.py.
This commit is contained in:
stefanfeng
2026-08-07 16:30:29 +08:00
parent 76f0730b57
commit 7327939b4d
4 changed files with 65 additions and 0 deletions
@@ -0,0 +1,26 @@
import pytest
from database import init_db, SessionLocal
from models import Authorization
@pytest.fixture(scope="session", autouse=True)
def setup_database():
"""Initialize DB tables and seed an Authorization row."""
init_db()
db = SessionLocal()
try:
existing = db.query(Authorization).first()
if existing is None:
auth = Authorization(
id="test-auth-1",
avatar_id="test-avatar-1",
target_type="user",
target_id="test-user-1",
target_name="Test User",
permissions=["read", "write"],
status="active",
)
db.add(auth)
db.commit()
finally:
db.close()