mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
fix: preserve legacy model query ABI
This commit is contained in:
+3
-2
@@ -13,8 +13,8 @@
|
||||
"runtime_to_db": [],
|
||||
"workflow_to_db": []
|
||||
},
|
||||
"edge_count": 6413,
|
||||
"edge_sha256": "02b7d1b32347dbd9be15ab2634c196dd36806fa9db89b0f8989ac6cc152c2b73",
|
||||
"edge_count": 6414,
|
||||
"edge_sha256": "aea2c4a5f65a9800bc69a83990efd368ba0ec7a9b19e40f38f8d0df6c222ae26",
|
||||
"edges": [
|
||||
"app -> app.runtime",
|
||||
"app -> app.runtime.compat",
|
||||
@@ -3473,6 +3473,7 @@
|
||||
"app.db.models.agentchat -> app.db.decorators",
|
||||
"app.db.models.agenttask -> app.db",
|
||||
"app.db.models.agenttask -> app.db.base",
|
||||
"app.db.models.agenttask -> app.db.decorators",
|
||||
"app.db.models.agenttaskrun -> app.db",
|
||||
"app.db.models.agenttaskrun -> app.db.base",
|
||||
"app.db.models.agenttaskrun -> app.db.decorators",
|
||||
|
||||
@@ -238,6 +238,20 @@ def test_passkey_lookup_by_credential_id_skips_inactive(db):
|
||||
assert asyncio.run(PassKey.async_get_by_credential_id(credential_id="cred-dead")) is None
|
||||
|
||||
|
||||
def test_passkey_model_sync_queries_keep_no_session_plugin_abi(db, monkeypatch):
|
||||
"""旧插件不传 Session 时仍应获得短会话查询,而不恢复 Model 装饰器。"""
|
||||
db.add(_passkey(9004, "cred-legacy"))
|
||||
monkeypatch.setattr(
|
||||
"app.db.models.passkey.run_legacy_sync_query",
|
||||
lambda operation: operation(db.session),
|
||||
)
|
||||
|
||||
assert [item.credential_id for item in PassKey.get_by_user_id(user_id=9004)] == [
|
||||
"cred-legacy"
|
||||
]
|
||||
assert PassKey.get_by_credential_id("cred-legacy").user_id == 9004
|
||||
|
||||
|
||||
def test_passkey_get_by_id_ignores_active_flag(db):
|
||||
"""
|
||||
按主键取记录是管理用途,不应过滤停用状态——否则管理端看不到自己刚停用的凭据。
|
||||
|
||||
@@ -308,6 +308,21 @@ def test_agenttask_get_for_user_enforces_ownership(db):
|
||||
assert AgentTask.get_for_user(db.session, task_id, user_id="bob") is None
|
||||
|
||||
|
||||
def test_agenttask_model_queries_keep_no_session_plugin_abi(db, monkeypatch):
|
||||
"""旧插件省略 Session 时仍可按原关键字参数查询 Agent 任务。"""
|
||||
task_id = AgentTask.add_task(db.session, **_task("legacy", user_id="legacy-user"))
|
||||
monkeypatch.setattr(
|
||||
"app.db.models.agenttask.run_legacy_sync_query",
|
||||
lambda operation: operation(db.session),
|
||||
)
|
||||
|
||||
assert AgentTask.get_for_user(
|
||||
task_id=task_id,
|
||||
user_id="legacy-user",
|
||||
).id == task_id
|
||||
assert [task.id for task in AgentTask.list_for_user(user_id="legacy-user")] == [task_id]
|
||||
|
||||
|
||||
def test_agenttask_oper_reads_with_explicit_session(db, monkeypatch):
|
||||
"""AgentTaskOper 的宿主查询使用调用方 Session,不再经过旧事务兼容执行器。"""
|
||||
task_id = AgentTask.add_task(db.session, **_task("canonical", user_id="alice"))
|
||||
|
||||
Reference in New Issue
Block a user