paths throughout to serialize as object.
all for clarity! ahh
This commit is contained in:
@@ -5,7 +5,7 @@ import shutil
|
||||
from typing import Any, cast
|
||||
|
||||
from wf_artifacts import FileDraftWorkspaceStore, WorkflowDeployment
|
||||
from wf_authoring import NodeSpec, build_async_registry
|
||||
from wf_authoring import NodeSpec, build_async_registry, node
|
||||
from wf_core import END, NodeUse, RunStatus, RuntimeContext
|
||||
from wf_mcp.broker import WfMcpService
|
||||
from wf_mcp.models import AuthRecord, ConnectionConfig, RawWorkflowPlan
|
||||
@@ -20,6 +20,8 @@ from wf_platform import (
|
||||
)
|
||||
|
||||
from .test_support import (
|
||||
EchoInput,
|
||||
EchoOutput,
|
||||
FailingDiscoveryAdapter,
|
||||
FakeAdapter,
|
||||
echo_tool,
|
||||
@@ -28,6 +30,11 @@ from .test_support import (
|
||||
)
|
||||
|
||||
|
||||
@node(name="foo.bar")
|
||||
def pro_dotted_echo_tool(payload: EchoInput) -> EchoOutput:
|
||||
return EchoOutput(echoed=f"pro:{payload.text}")
|
||||
|
||||
|
||||
def _single_echo_plan(plan_name: str, node_name: str) -> RawWorkflowPlan:
|
||||
return _raw_plan(
|
||||
name=plan_name,
|
||||
@@ -476,6 +483,50 @@ def test_service_runs_logical_source_plan_with_dotted_local_name() -> None:
|
||||
assert run.output["echoed"] == "hello"
|
||||
|
||||
|
||||
def test_service_binds_longest_logical_source_prefix_first() -> None:
|
||||
service = WfMcpService(
|
||||
store=FileStore(local_temp_root() / "longest_logical_source_prefix")
|
||||
)
|
||||
service.register_connection(
|
||||
ConnectionConfig(id="demo.personal", server="demo", account="personal")
|
||||
)
|
||||
service.register_connection(
|
||||
ConnectionConfig(
|
||||
id="demo.pro.personal",
|
||||
server="demo",
|
||||
account="pro.personal",
|
||||
)
|
||||
)
|
||||
service.register_specs("demo.personal", echo_tool)
|
||||
service.register_specs("demo.pro.personal", pro_dotted_echo_tool)
|
||||
plan = _single_echo_plan(
|
||||
"longest_logical_source_prefix_plan",
|
||||
"demo.pro.foo.bar",
|
||||
)
|
||||
|
||||
run = asyncio.run(
|
||||
service.run_workflow_from_plan(
|
||||
plan,
|
||||
{"text": "hello"},
|
||||
deployment=WorkflowDeployment(
|
||||
id="longest_logical_source_prefix.personal",
|
||||
artifact_id="longest_logical_source_prefix",
|
||||
artifact_version=1,
|
||||
bindings=[
|
||||
{"logical_source": "demo", "concrete_source": "demo.personal"},
|
||||
{
|
||||
"logical_source": "demo.pro",
|
||||
"concrete_source": "demo.pro.personal",
|
||||
},
|
||||
],
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assert run.status == RunStatus.COMPLETED
|
||||
assert run.output["echoed"] == "pro:hello"
|
||||
|
||||
|
||||
def test_service_does_not_resolve_specs_hidden_from_planner() -> None:
|
||||
service = WfMcpService(store=FileStore(local_temp_root() / "hidden_spec_store"))
|
||||
hidden_echo_tool = NodeSpec(
|
||||
|
||||
@@ -14,6 +14,19 @@ def test_workflow_surface_capability_id_parses_live_capability_ref() -> None:
|
||||
assert capability.name == "echo_tool"
|
||||
|
||||
|
||||
def test_workflow_surface_capability_id_parses_structural_live_capability_ref() -> None:
|
||||
capability = parse_workflow_surface_capability_id(
|
||||
{
|
||||
"source": "demo",
|
||||
"capability_key": "foo.bar",
|
||||
}
|
||||
)
|
||||
|
||||
assert isinstance(capability, CapabilityRef)
|
||||
assert str(capability.source) == "demo"
|
||||
assert capability.name == "foo.bar"
|
||||
|
||||
|
||||
def test_workflow_surface_capability_id_parses_saved_wrapper_ref() -> None:
|
||||
capability = parse_workflow_surface_capability_id("workflow.echo_wrapper.v2")
|
||||
|
||||
@@ -21,3 +34,15 @@ def test_workflow_surface_capability_id_parses_saved_wrapper_ref() -> None:
|
||||
assert str(capability) == "workflow.echo_wrapper.v2"
|
||||
assert capability.artifact_id == "echo_wrapper"
|
||||
assert capability.version == 2
|
||||
|
||||
|
||||
def test_workflow_surface_capability_id_parses_structural_saved_wrapper_ref() -> None:
|
||||
capability = parse_workflow_surface_capability_id(
|
||||
{
|
||||
"artifact_id": "echo_wrapper",
|
||||
"version": 2,
|
||||
}
|
||||
)
|
||||
|
||||
assert isinstance(capability, WorkflowCapabilityRef)
|
||||
assert str(capability) == "workflow.echo_wrapper.v2"
|
||||
|
||||
Reference in New Issue
Block a user