mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
test(agent): isolate scheduler in task run test (#6311)
This commit is contained in:
@@ -313,10 +313,15 @@ async def test_query_task_returns_owner_scoped_ten_recent_runs(monkeypatch) -> N
|
|||||||
assert other_run
|
assert other_run
|
||||||
assert oper.finish_run(other_run.run_id, success=True, result="其他用户")
|
assert oper.finish_run(other_run.run_id, success=True, result="其他用户")
|
||||||
|
|
||||||
monkeypatch.setattr(
|
class _SchedulerStub:
|
||||||
"app.scheduler.Scheduler.get_agent_task_next_run",
|
"""为查询工具提供下一次触发时间,避免启动真实 APScheduler。"""
|
||||||
lambda _self, _task_id: None,
|
|
||||||
)
|
@staticmethod
|
||||||
|
def get_agent_task_next_run(_task_id):
|
||||||
|
"""返回测试任务不需要的下一次触发时间。"""
|
||||||
|
return None
|
||||||
|
|
||||||
|
monkeypatch.setattr("app.scheduler.Scheduler", _SchedulerStub)
|
||||||
detail = json.loads(await _build_query_tool(task.user_id).run(task_id=task.id))
|
detail = json.loads(await _build_query_tool(task.user_id).run(task_id=task.id))
|
||||||
assert detail["total"] == 1
|
assert detail["total"] == 1
|
||||||
assert [run["run_id"] for run in detail["tasks"][0]["recent_runs"]] == expected[:10]
|
assert [run["run_id"] for run in detail["tasks"][0]["recent_runs"]] == expected[:10]
|
||||||
|
|||||||
Reference in New Issue
Block a user