mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +08:00
refactor: finish transactional runtime migration
This commit is contained in:
@@ -13,6 +13,7 @@ from app.db.models.passkey import PassKey
|
||||
from app.db.models.systemconfig import SystemConfig
|
||||
from app.db.models.user import User
|
||||
from app.db.models.userconfig import UserConfig
|
||||
from app.db.oper.passkey import PassKeyOper
|
||||
from app.db.oper.user import UserOper
|
||||
|
||||
|
||||
@@ -171,12 +172,12 @@ def test_user_async_mutations_match_sync_behaviour(db):
|
||||
db.add(User(name="mp-test-async-otp", hashed_password="x", is_otp=False))
|
||||
oper = UserOper()
|
||||
|
||||
assert asyncio.run(User.async_update_otp_by_name(
|
||||
assert asyncio.run(oper.async_update_otp_by_name(
|
||||
name="mp-test-async-otp", otp=True, secret="S2")) is True
|
||||
assert asyncio.run(User.async_update_otp_by_name(
|
||||
assert asyncio.run(oper.async_update_otp_by_name(
|
||||
name="mp-test-nobody", otp=True, secret="S2")) is False
|
||||
|
||||
assert asyncio.run(User().async_delete_by_name(name="mp-test-async-otp")) is True
|
||||
assert asyncio.run(oper.async_delete_by_name(name="mp-test-async-otp")) is True
|
||||
assert User.get_by_name(db.session, "mp-test-async-otp") is None
|
||||
|
||||
asyncio.run(oper.async_delete(async_id_user.id))
|
||||
@@ -253,8 +254,9 @@ def test_passkey_async_delete_enforces_the_same_ownership_rule(db):
|
||||
"""
|
||||
victim = db.add(_passkey(9006, "cred-async-victim"))
|
||||
|
||||
assert asyncio.run(PassKey.async_delete_by_id(passkey_id=victim.id, user_id=9999)) is False
|
||||
assert asyncio.run(PassKey.async_delete_by_id(passkey_id=victim.id, user_id=9006)) is True
|
||||
oper = PassKeyOper()
|
||||
assert asyncio.run(oper.async_delete_by_id(passkey_id=victim.id, user_id=9999)) is False
|
||||
assert asyncio.run(oper.async_delete_by_id(passkey_id=victim.id, user_id=9006)) is True
|
||||
assert PassKey.get_by_id(db.session, victim.id) is None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user