mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-05 06:39:33 +08:00
Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""插件工作流动作标识的公开契约与执行回归。"""
|
||||
"""
|
||||
插件工作流动作标识的公开契约与执行回归。
|
||||
"""
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
@@ -7,7 +9,9 @@ from app.workflow.actions.invoke_plugin import InvokePluginAction
|
||||
|
||||
|
||||
def _execute_with_action(action: dict) -> tuple[InvokePluginAction, ActionContext]:
|
||||
"""在最小运行时替身中执行一个插件动作。"""
|
||||
"""
|
||||
在最小运行时替身中执行一个插件动作。
|
||||
"""
|
||||
context = ActionContext(content="before")
|
||||
action_fn = Mock(return_value=(True, context))
|
||||
action["func"] = action_fn
|
||||
@@ -41,21 +45,26 @@ def _execute_with_action(action: dict) -> tuple[InvokePluginAction, ActionContex
|
||||
|
||||
|
||||
def test_invoke_plugin_uses_public_action_id() -> None:
|
||||
"""插件公开的 id 字段必须可被工作流执行器解析。"""
|
||||
"""
|
||||
插件公开的 id 字段必须可被工作流执行器解析。
|
||||
"""
|
||||
_, result = _execute_with_action({"id": "cleanup"})
|
||||
|
||||
assert result.content == "before"
|
||||
|
||||
|
||||
def test_invoke_plugin_keeps_legacy_action_id_fallback() -> None:
|
||||
"""历史插件声明仍可通过 action_id 回退执行。"""
|
||||
"""
|
||||
历史插件声明仍可通过 action_id 回退执行。
|
||||
"""
|
||||
_, result = _execute_with_action({"action_id": "cleanup"})
|
||||
|
||||
assert result.content == "before"
|
||||
|
||||
|
||||
def test_invoke_plugin_dispatches_to_resolved_default_target() -> None:
|
||||
"""插件 ID 有分身时,动作按裁决出的默认调用目标查询动作,而不是原样使用插件 ID。
|
||||
"""
|
||||
插件 ID 有分身时,动作按裁决出的默认调用目标查询动作,而不是原样使用插件 ID。
|
||||
|
||||
这是历史工作流在源插件本体停用、仅分身启用后仍能继续工作的关键:存量工作流
|
||||
保存的还是物理插件 ID,必须经过默认调用目标裁决才能落到实际在跑的分身上。
|
||||
@@ -94,7 +103,9 @@ def test_invoke_plugin_dispatches_to_resolved_default_target() -> None:
|
||||
|
||||
|
||||
def test_invoke_plugin_fails_gracefully_when_default_target_undecidable() -> None:
|
||||
"""裁决报错(未设默认目标/默认目标已停用)时动作失败但不抛出,不误执行任何实例。"""
|
||||
"""
|
||||
裁决报错(未设默认目标/默认目标已停用)时动作失败但不抛出,不误执行任何实例。
|
||||
"""
|
||||
context = ActionContext(content="before")
|
||||
plugin_manager = Mock()
|
||||
plugin_manager.resolve_plugin_call_target.side_effect = LookupError(
|
||||
|
||||
Reference in New Issue
Block a user