refactor(ops): 按功能划分重构 ops/ 结构 — 22 个工具归入 files/dev/system/infra 子包, pf 动态导入注册表, 测试导入路径同步
CI / Lint, Typecheck & Test (push) Has been cancelled

This commit is contained in:
2026-07-07 08:43:36 +08:00
parent c502556db9
commit d733452c8a
52 changed files with 647 additions and 238 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Tests for pf._TOOL_MODULES 注册表完整性.
防止新增工具时遗漏 ``_TOOL_MODULES`` 注册项, 导致 ``pf <新工具>`` 静默失败.
"""
from __future__ import annotations
import importlib
import pytest
from pyflowx.cli.pf import PfApp
class TestToolModulesComplete:
"""``_TOOL_MODULES`` 必须覆盖 ``_TOOL_ALIASES`` 的所有规范名."""
def test_all_canonical_tools_have_module_path(self) -> None:
"""``_TOOL_ALIASES`` 的每个规范名都应在 ``_TOOL_MODULES`` 中有对应模块路径."""
canonical_names = set(PfApp._TOOL_ALIASES.values())
module_names = set(PfApp._TOOL_MODULES)
missing = canonical_names - module_names
assert not missing, f"未在 _TOOL_MODULES 注册的工具: {missing}"
@pytest.mark.parametrize("tool_name, module_path", sorted(PfApp._TOOL_MODULES.items()))
def test_module_importable(self, tool_name: str, module_path: str) -> None:
"""每个注册的模块路径必须可导入."""
importlib.import_module(module_path)