agent_deply/tests/test_graph.py
dark a11904b7c5 docs/build: 补齐中文注释、流程图和 Linux 解压即用打包脚本
- 为 pam_deploy_graph 生产代码补充中文模块、类、函数/方法文档字符串
- 将原有英文说明和主要英文异常提示改为中文
- 新增当前整体逻辑结构流程图文档,覆盖模块结构、执行链路、action 路由、人工确认和 checkpoint 续跑
- 新增 Linux 自带运行环境打包脚本,使用 PyInstaller 生成解压即用目录和 tar.gz
- 新增 Linux 打包说明,包含构建命令、运行方式、依赖说明和包大小评估
- 同步 README,补充流程图、打包方式、产物路径和大小预估
- 更新相关测试断言以匹配中文错误提示
2026-06-01 11:21:42 +08:00

38 lines
1.2 KiB
Python

import importlib.util
import pytest
from pam_deploy_graph.graph import build_graph_or_none, build_langgraph
from pam_deploy_graph.params_loader import load_params_file
def test_build_graph_or_none_without_langgraph_is_safe():
graph = build_graph_or_none()
if importlib.util.find_spec("langgraph"):
assert graph is not None
else:
assert graph is None
def test_build_langgraph_error_without_dependency_is_clear():
if importlib.util.find_spec("langgraph"):
pytest.skip("langgraph installed")
with pytest.raises(RuntimeError, match="未安装 langgraph"):
build_langgraph()
def test_langgraph_invokes_global_flow_when_installed(tmp_path):
if not importlib.util.find_spec("langgraph"):
pytest.skip("langgraph not installed")
graph = build_langgraph(flow="global")
result = graph.invoke(
{
"params": load_params_file("doc_scripts/config.txt.example"),
"execution_strategy": "fake",
"config_path": str(tmp_path / "config.txt"),
}
)
state = result["agent_state"]
assert state.completed_global_steps[-1] == "poll-download-progress"
assert state.action_backends["get-online-ips"] == "fake"