fix: 修复用户异步删除和 OTP 更新

This commit is contained in:
jxxghp
2026-08-22 10:25:35 +08:00
parent 508bf0bc38
commit b8c79e1a1e
2 changed files with 16 additions and 6 deletions
+8 -2
View File
@@ -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.user import UserOper
@pytest.fixture(autouse=True)
@@ -166,16 +167,21 @@ def test_user_async_mutations_match_sync_behaviour(db):
"""
异步的删除与 OTP 更新必须与同步路径给出相同的存在性判断。
"""
async_id_user = db.add(User(name="mp-test-async-id", hashed_password="x"))
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(User.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(User.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 User.get_by_name(db.session, "mp-test-async-otp") is None
asyncio.run(oper.async_delete(async_id_user.id))
assert User.get_by_id(db.session, async_id_user.id) is None
# --------------------------------------------------------------------------- #
# PassKey