mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: unify workflow data port access
This commit is contained in:
@@ -407,6 +407,27 @@ def test_host_code_uses_explicit_runtime_facade_getters():
|
||||
assert violations == []
|
||||
|
||||
|
||||
def test_workflow_domain_uses_explicit_chain_data_port_getters():
|
||||
"""工作流域不得重新使用迁移期 PortProxy 冒充数据库 Oper。"""
|
||||
paths = [APP_ROOT / "chain" / "workflow.py"]
|
||||
paths.extend((APP_ROOT / "workflow").rglob("*.py"))
|
||||
violations: list[str] = []
|
||||
for path in paths:
|
||||
tree = ast.parse(path.read_text(encoding="utf-8-sig"), filename=str(path))
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.ImportFrom):
|
||||
continue
|
||||
if node.module != "app.application.chain.data":
|
||||
continue
|
||||
for alias in node.names:
|
||||
if alias.name.endswith("PortProxy"):
|
||||
violations.append(
|
||||
f"{path.relative_to(PROJECT_ROOT).as_posix()}:{node.lineno}:{alias.name}"
|
||||
)
|
||||
|
||||
assert violations == []
|
||||
|
||||
|
||||
def test_plugin_components_do_not_reexport_legacy_abi_names():
|
||||
"""新插件组件只提供 canonical 能力,不得复制旧 Helper、Manager 或 Oper 导出。"""
|
||||
violations: list[str] = []
|
||||
|
||||
@@ -635,7 +635,7 @@ def test_workflow_chain_process_serializes_circular_context(monkeypatch):
|
||||
fake_oper = _FakeWorkflowOper(workflow)
|
||||
|
||||
monkeypatch.setattr(workflow_module, "get_workflow_manager", lambda: fake_manager)
|
||||
monkeypatch.setattr(workflow_module, "WorkflowOper", lambda: fake_oper)
|
||||
monkeypatch.setattr(workflow_module, "get_chain_workflow_port", lambda: fake_oper)
|
||||
monkeypatch.setattr(workflow_module.global_vars, "workflow_resume", lambda workflow_id: None)
|
||||
monkeypatch.setattr(workflow_module.global_vars, "is_workflow_stopped", lambda workflow_id: False)
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ def test_add_subscribe_uses_superuser_from_chain_snapshot(monkeypatch):
|
||||
monkeypatch.setattr(add_subscribe_module.global_vars, "is_workflow_stopped", lambda _: False)
|
||||
monkeypatch.setattr(
|
||||
add_subscribe_module,
|
||||
"SubscribeOper",
|
||||
"get_chain_subscribe_port",
|
||||
lambda: SimpleNamespace(get=lambda sid: sid),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user