code review
This commit is contained in:
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from wf_artifacts import FileWorkflowArtifactStore
|
||||
from wf_api.capabilities import WorkflowCapabilityApi
|
||||
from wf_mcp.broker import WfMcpService
|
||||
@@ -91,11 +93,8 @@ def test_inspect_capability_raises_on_unknown() -> None:
|
||||
)
|
||||
api, _service = _capability_api(artifact_store, register_echo=True)
|
||||
|
||||
try:
|
||||
with pytest.raises(KeyError, match="no.such.capability"):
|
||||
asyncio.run(api.inspect_capability(qualified_name="no.such.capability"))
|
||||
assert False, "expected KeyError"
|
||||
except KeyError as exc:
|
||||
assert "no.such.capability" in str(exc)
|
||||
|
||||
|
||||
def test_call_capability_node_spec_success() -> None:
|
||||
|
||||
@@ -286,7 +286,7 @@ def test_validate_draft_workspace_refreshes_status() -> None:
|
||||
assert fetched["status"] == "invalid"
|
||||
|
||||
|
||||
def test_create_minimal_draft_workspace_with_error_route() -> None:
|
||||
def test_create_minimal_draft_workspace_minimal_success_path() -> None:
|
||||
artifact_store = FileWorkflowArtifactStore(
|
||||
local_temp_root() / "drafts_minimal_workspace"
|
||||
)
|
||||
|
||||
@@ -15,15 +15,13 @@ def test_wf_api_has_no_wf_mcp_imports() -> None:
|
||||
tree = ast.parse(py_file.read_text(encoding="utf-8"), filename=str(py_file))
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.ImportFrom) and node.module is not None:
|
||||
if node.module.startswith("wf_mcp") or node.module.startswith(
|
||||
"wf_mcp."
|
||||
):
|
||||
if node.module == "wf_mcp" or node.module.startswith("wf_mcp."):
|
||||
violations.append(
|
||||
f"{module}:{node.lineno}: from {node.module} import ..."
|
||||
)
|
||||
elif isinstance(node, ast.Import):
|
||||
for alias in node.names:
|
||||
if alias.name.startswith("wf_mcp"):
|
||||
if alias.name == "wf_mcp" or alias.name.startswith("wf_mcp."):
|
||||
violations.append(
|
||||
f"{module}:{node.lineno}: import {alias.name}"
|
||||
)
|
||||
|
||||
@@ -3,6 +3,8 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from wf_artifacts import FileWorkflowArtifactStore, WorkflowDeployment
|
||||
from wf_api.runs import WorkflowRunApi
|
||||
from wf_mcp.broker import WfMcpService
|
||||
@@ -159,6 +161,29 @@ def test_run_api_inspect_and_bounded_trace() -> None:
|
||||
assert trace["trace_count"] == summary["trace_count"]
|
||||
|
||||
|
||||
def test_run_api_rejects_invalid_trace_range_before_store_lookup() -> None:
|
||||
root = local_temp_root() / "run_api_invalid_trace_range"
|
||||
service, _ = _service_with_echo(root)
|
||||
context = context_from_service(service)
|
||||
api = WorkflowRunApi(context)
|
||||
|
||||
with pytest.raises(ValueError, match="trace_range.start"):
|
||||
asyncio.run(
|
||||
api.read_run_trace(
|
||||
run_id="missing",
|
||||
trace_range=SimpleTraceRange(start=-1, limit=1),
|
||||
)
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="trace_range.limit"):
|
||||
asyncio.run(
|
||||
api.read_run_trace(
|
||||
run_id="missing",
|
||||
trace_range=SimpleTraceRange(start=0, limit=0),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_run_api_handler_delegation_matches() -> None:
|
||||
root = local_temp_root() / "run_api_delegation"
|
||||
service, _ = _service_with_echo(root)
|
||||
|
||||
Reference in New Issue
Block a user