agent_deply/tests/test_script_runner.py
dark 039a3e1bdc 支持云下载继承版本参数并调整回滚请求格式
- 新增 PARENT_VERSION_NUMBER 可选配置,默认空值不传
- create-download-task 非空时透传 parentVersionNumber
- 支持 LLM/规则从自然语言和 key=value 中抽取继承版本参数
- 将 rollback 接口参数从表单 body 改为 URL query 拼接
- 同步 README、打包说明和 Skill 文档
- 增加 MCP 参数透传、配置写入和 rollback query 调用测试
2026-06-05 10:33:53 +08:00

71 lines
2.0 KiB
Python

from pathlib import Path
from pam_deploy_graph.script_runner import ScriptActionRunner
def test_build_shell_action_command():
runner = ScriptActionRunner()
command = runner.build_command(
"publish-version",
script_entry="deploy.sh",
config_path="./config.txt",
hash_code="abc",
trace_file_path="./logs/trace.log",
)
assert command == [
"bash",
"./deploy.sh",
"--config",
"./config.txt",
"--action",
"publish-version",
"--hash-code",
"abc",
"--trace-file",
"./logs/trace.log",
]
def test_build_powershell_action_command():
runner = ScriptActionRunner()
command = runner.build_command(
"rollback-ip",
script_entry="deploy.ps1",
config_path=".\\config.txt",
ip="192.168.1.10",
stop_first=True,
)
assert command == [
"powershell",
"-File",
".\\deploy.ps1",
"-ConfigPath",
".\\config.txt",
"-Action",
"rollback-ip",
"-Ip",
"192.168.1.10",
"-RollbackStopFirst",
]
def test_shell_rollback_uses_query_parameters_not_form_body():
text = Path("doc_scripts/deploy.sh").read_text(encoding="utf-8")
start = text.index("rollback_ip()")
end = text.index("run_manual_rollback()", start)
rollback_block = text[start:end]
assert "/api/mcp/version/upgrade/rollback?${rollback_query}" in rollback_block
assert "application/x-www-form-urlencoded" not in rollback_block
def test_powershell_rollback_uses_query_parameters_not_form_body():
text = Path("doc_scripts/deploy.ps1").read_text(encoding="utf-8")
start = text.index("function Invoke-Rollback")
end = text.index("function Invoke-IpDeploy", start)
rollback_block = text[start:end]
assert "/api/mcp/version/upgrade/rollback?$query" in rollback_block
assert "-Body $body" not in rollback_block
assert "application/x-www-form-urlencoded" not in rollback_block