mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor(chain): 处理链功能域 mixin 化,清理未使用导入并根治兼容层循环导入
- ChainBase 拆分为 RecognitionMixin/MessageProcessingMixin/NotificationMixin - TransferChain 拆分为 7 个功能 mixin(_mixins.py),SubscribeChain 音乐订阅域拆出 _music.py - 斜杠命令交互四件套收敛为 InteractionChainMixin 委托,会话管理器移至 application 层,chain 层不再 re-export - 模块基础类收敛到 app/modules/_base(notification/mediaserver 语义重命名) - 清理 app/chain/__init__.py 24 个未使用导入,修正 49 处测试 patch 目标到实际命名空间 - 兼容层 legacy 符号不再并入 __all__,根治 schemas 初始化反向拉起 application.transfer 的循环导入 - 修复 bangumi 集数为字符串时 set_bangumi_info 抛 TypeError - 新增重复代码等架构门禁测试;capability 清单校验排除下划线内部目录
This commit is contained in:
@@ -431,6 +431,10 @@ async def test_interrupted_date_task_enable_toggle_stays_manual_only(
|
||||
scheduler = _build_agent_task_scheduler()
|
||||
scheduler.init_agent_task_jobs()
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: scheduler,
|
||||
)
|
||||
tool = _build_tool(UpdateAgentTaskTool, task.user_id)
|
||||
|
||||
paused = json.loads(await tool.run(task_id=task.id, enabled=False))
|
||||
@@ -458,6 +462,10 @@ async def test_interrupted_date_task_new_trigger_rearms_schedule(monkeypatch) ->
|
||||
scheduler = _build_agent_task_scheduler()
|
||||
scheduler.init_agent_task_jobs()
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: scheduler,
|
||||
)
|
||||
updated = json.loads(
|
||||
await _build_tool(UpdateAgentTaskTool, task.user_id).run(
|
||||
task_id=task.id,
|
||||
@@ -487,6 +495,10 @@ async def test_interrupted_date_task_rejects_past_trigger_while_pausing(
|
||||
scheduler = _build_agent_task_scheduler()
|
||||
scheduler.init_agent_task_jobs()
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: scheduler,
|
||||
)
|
||||
tool = _build_tool(UpdateAgentTaskTool, task.user_id)
|
||||
|
||||
with pytest.raises(ValueError, match="必须晚于当前时间"):
|
||||
@@ -521,6 +533,10 @@ async def test_expired_date_task_rejects_enable_without_reschedule(
|
||||
scheduler = _build_agent_task_scheduler()
|
||||
scheduler.init_agent_task_jobs()
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: scheduler,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="必须晚于当前时间"):
|
||||
await _build_tool(UpdateAgentTaskTool, task.user_id).run(
|
||||
@@ -734,6 +750,10 @@ async def test_scheduler_tools_exclude_agent_tasks(monkeypatch) -> None:
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: scheduler,
|
||||
)
|
||||
tool = _build_tool(QuerySchedulersTool, "admin-user")
|
||||
|
||||
result = json.loads(await tool.run())
|
||||
@@ -763,6 +783,10 @@ async def test_agent_task_tools_manage_persistent_schedule(monkeypatch) -> None:
|
||||
user_id = f"user-{uuid4().hex}"
|
||||
fake_scheduler = _FakeAgentTaskScheduler()
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: fake_scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: fake_scheduler,
|
||||
)
|
||||
|
||||
create_tool = _build_tool(CreateAgentTaskTool, user_id)
|
||||
created = json.loads(await create_tool.ainvoke({
|
||||
@@ -843,6 +867,10 @@ async def test_run_agent_task_enforces_owner_and_enabled_state(monkeypatch) -> N
|
||||
)
|
||||
fake_scheduler = _FakeAgentTaskScheduler()
|
||||
monkeypatch.setattr("app.scheduler.Scheduler", lambda: fake_scheduler)
|
||||
monkeypatch.setattr(
|
||||
"app.application.scheduling._scheduler_class",
|
||||
lambda: fake_scheduler,
|
||||
)
|
||||
|
||||
other_user_result = await _build_tool(
|
||||
RunAgentTaskTool,
|
||||
|
||||
Reference in New Issue
Block a user