Files
pyflowx/tests/cli/test_pymake_tool.py
T
zhou e31646e281 feat: 新增envdev、gittool、msdownload、pymake工具模块及对应测试用例
新增四个业务工具模块:
1. envdev: 开发环境镜像源配置工具,支持Python/Conda/Rust镜像配置及Linux系统环境配置
2. gittool: Git操作工具,提供提交、初始化、清理、推送等快捷子命令
3. msdownload: ModelScope模型/数据集下载工具
4. pymake: 项目构建工具,覆盖构建、测试、发布等全流程开发操作

同时为每个工具模块编写了完整的注册验证与功能测试用例
2026-07-06 13:11:09 +08:00

109 lines
3.8 KiB
Python

"""Tests for ops.pymake 模块 (@px.tool 注册验证)."""
from __future__ import annotations
import pyflowx as px
import pyflowx.ops.pymake
from pyflowx.tools import _TOOL_REGISTRY, get_tool
# ---------------------------------------------------------------------- #
# @px.tool 注册验证
# ---------------------------------------------------------------------- #
class TestPymakeRegistration:
"""``pymake`` 模块 ``@px.tool`` 注册验证."""
def test_pymake_registered(self) -> None:
"""pymake 应在 _TOOL_REGISTRY 中注册."""
assert "pymake" in _TOOL_REGISTRY
def test_visible_subcommands(self) -> None:
"""可见子命令应包含核心构建/测试命令."""
subs = px.list_subcommands("pymake")
assert "b" in subs
assert "bc" in subs
assert "sync" in subs
assert "c" in subs
assert "t" in subs
assert "tf" in subs
assert "lint" in subs
assert "tox" in subs
assert "ba" in subs
assert "bump" in subs
assert "cov" in subs
assert "tc" in subs
assert "p" in subs
def test_hidden_subcommands_excluded(self) -> None:
"""hidden 子命令不应出现在可见列表中."""
subs = px.list_subcommands("pymake")
assert "pyrefly_check" not in subs
assert "git_push" not in subs
assert "git_push_tags" not in subs
assert "twine_publish" not in subs
assert "publish_python" not in subs
def test_hidden_subcommands_included_with_flag(self) -> None:
"""include_hidden=True 时 hidden 子命令应出现."""
subs = px.list_subcommands("pymake", include_hidden=True)
assert "pyrefly_check" in subs
assert "git_push" in subs
assert "git_push_tags" in subs
assert "twine_publish" in subs
assert "publish_python" in subs
def test_b_has_cmd(self) -> None:
"""b 应有 cmd (uv build)."""
spec = get_tool("pymake", "b")
assert spec.cmd is not None
assert "uv" in spec.cmd
assert "build" in spec.cmd
def test_bc_has_cmd(self) -> None:
"""bc 应有 cmd (maturin build)."""
spec = get_tool("pymake", "bc")
assert spec.cmd is not None
assert "maturin" in spec.cmd
def test_ba_needs_b_and_bc(self) -> None:
"""ba 应依赖 b 和 bc."""
spec = get_tool("pymake", "ba")
assert "b" in spec.needs
assert "bc" in spec.needs
assert spec.cmd is None
def test_tc_needs_c_pyrefly_lint(self) -> None:
"""tc 应依赖 c, pyrefly_check, lint."""
spec = get_tool("pymake", "tc")
assert "c" in spec.needs
assert "pyrefly_check" in spec.needs
assert "lint" in spec.needs
def test_cov_needs_test_coverage(self) -> None:
"""cov 应依赖 test_coverage."""
spec = get_tool("pymake", "cov")
assert "test_coverage" in spec.needs
def test_p_needs_c_git_push(self) -> None:
"""p 应依赖 c, git_push, git_push_tags."""
spec = get_tool("pymake", "p")
assert "c" in spec.needs
assert "git_push" in spec.needs
assert "git_push_tags" in spec.needs
def test_bumpversion_needs_git_add_all(self) -> None:
"""bumpversion 应依赖 git_add_all."""
spec = get_tool("pymake", "bumpversion")
assert "git_add_all" in spec.needs
def test_git_add_all_needs_tc(self) -> None:
"""git_add_all 应依赖 tc."""
spec = get_tool("pymake", "git_add_all")
assert "tc" in spec.needs
def test_aggregate_tasks_have_no_cmd(self) -> None:
"""聚合任务 (ba/bump/cov/tc/p) 应无 cmd."""
for name in ("ba", "bump", "cov", "tc", "p"):
spec = get_tool("pymake", name)
assert spec.cmd is None, f"{name} 应为聚合任务 (无 cmd)"