code review
This commit is contained in:
@@ -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(
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user