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,30 @@
from database import SessionLocal
from models import Authorization
def test_authorization_takeover_fields():
db = SessionLocal()
try:
auth = db.query(Authorization).first()
assert auth is not None
# Check new fields exist and have default values
assert hasattr(auth, 'takeover_enabled')
assert hasattr(auth, 'takeover_mode')
assert hasattr(auth, 'takeover_delay_seconds')
assert auth.takeover_enabled == False
assert auth.takeover_mode == 'immediate'
assert auth.takeover_delay_seconds == 30
finally:
db.close()
def test_authorization_to_dict_includes_takeover():
db = SessionLocal()
try:
auth = db.query(Authorization).first()
d = auth.to_dict()
assert 'takeoverEnabled' in d
assert 'takeoverMode' in d
assert 'takeoverDelaySeconds' in d
finally:
db.close()