code review

This commit is contained in:
lda
2026-06-01 05:18:54 +07:00 Verified
parent 8740b495b9
commit e4813ad15e
10 changed files with 594 additions and 19 deletions
+5 -6
View File
@@ -1,16 +1,15 @@
from __future__ import annotations
import json
from pathlib import Path
from wf_cli.context import load_cli_context
from ..wf_mcp.test_support import local_temp_root
def test_load_cli_context_builds_service_and_handlers() -> None:
tmp_path = local_temp_root() / "wf_cli_context"
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
def test_load_cli_context_builds_service_and_handlers(tmp_path: Path) -> None:
root = tmp_path / "wf_cli_context"
root.mkdir()
config_path = root / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
+25
View File
@@ -66,6 +66,26 @@ def test_render_list_payload_json_returns_pretty_json() -> None:
assert parsed["deployments"][0]["id"] == "echo.personal"
def test_render_list_payload_rejects_missing_collection_key() -> None:
with pytest.raises(ValueError, match="missing required field 'nodes'"):
render_list_payload(
{"capabilities": []},
collection_key="nodes",
output_format=ListOutputFormat.IDS,
id_field="name",
)
def test_render_list_payload_rejects_non_array_collection() -> None:
with pytest.raises(ValueError, match="field 'nodes' must be an array"):
render_list_payload(
{"nodes": {}},
collection_key="nodes",
output_format=ListOutputFormat.IDS,
id_field="name",
)
def test_parse_json_value_accepts_arrays_for_json_patch() -> None:
value = parse_json_value(
input_json='[{"op":"replace","path":"/name","value":"x"}]', input_file=None
@@ -88,6 +108,11 @@ def test_parse_bindings_rejects_invalid_shape() -> None:
parse_bindings(["demo.personal"])
def test_parse_bindings_rejects_duplicate_logical_source() -> None:
with pytest.raises(CliInputError, match="duplicate --binding"):
parse_bindings(["demo=demo.personal", "demo=demo.work"])
runner = CliRunner()
+1 -1
View File
@@ -215,4 +215,4 @@ def test_wf_run_start_reports_bad_json() -> None:
)
assert result.exit_code != 0
assert "invalid JSON" in result.output
assert "invalid JSON" in result.stderr