fix: clean basedpyright test errors
This commit is contained in:
@@ -162,7 +162,7 @@ def migrate_broker_config_file(path: str | Path) -> WorkflowConfigFile:
|
|||||||
def build_service_from_config(config: BrokerConfig) -> WfMcpService:
|
def build_service_from_config(config: BrokerConfig) -> WfMcpService:
|
||||||
"""Create a broker service with SDK adapters for configured connections."""
|
"""Create a broker service with SDK adapters for configured connections."""
|
||||||
runtime_factory = PersistentSessionFactory()
|
runtime_factory = PersistentSessionFactory()
|
||||||
store_roots = config.store_roots or BrokerStoreRoots.from_default(config.store_root)
|
store_roots = config.store_roots
|
||||||
workflow_stores = file_workflow_stores(store_roots.workflow_root)
|
workflow_stores = file_workflow_stores(store_roots.workflow_root)
|
||||||
# Keep FileStore as the compatibility facade on WfMcpService.store while
|
# Keep FileStore as the compatibility facade on WfMcpService.store while
|
||||||
# focused services receive role-specific stores.
|
# focused services receive role-specific stores.
|
||||||
|
|||||||
@@ -43,15 +43,21 @@ class ConnectionConfig:
|
|||||||
source_config_ownership: SourceConfigOwnership = "locked"
|
source_config_ownership: SourceConfigOwnership = "locked"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(slots=True)
|
@dataclass(slots=True, init=False)
|
||||||
class BrokerConfig:
|
class BrokerConfig:
|
||||||
store_root: Path
|
store_root: Path
|
||||||
connections: list[ConnectionConfig] = field(default_factory=list)
|
connections: list[ConnectionConfig]
|
||||||
store_roots: BrokerStoreRoots | None = None
|
store_roots: BrokerStoreRoots
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
def __init__(
|
||||||
if self.store_roots is None:
|
self,
|
||||||
self.store_roots = BrokerStoreRoots.from_default(self.store_root)
|
store_root: Path,
|
||||||
|
connections: list[ConnectionConfig] | None = None,
|
||||||
|
store_roots: BrokerStoreRoots | None = None,
|
||||||
|
) -> None:
|
||||||
|
self.store_root = store_root
|
||||||
|
self.connections = [] if connections is None else connections
|
||||||
|
self.store_roots = store_roots or BrokerStoreRoots.from_default(store_root)
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ def workflow_server_from_service(
|
|||||||
def build_workflow_server_from_config(config: BrokerConfig) -> WorkflowServer:
|
def build_workflow_server_from_config(config: BrokerConfig) -> WorkflowServer:
|
||||||
"""Build a neutral WorkflowServer backed by MCP broker runtime services."""
|
"""Build a neutral WorkflowServer backed by MCP broker runtime services."""
|
||||||
service = build_service_from_config(config)
|
service = build_service_from_config(config)
|
||||||
assert config.store_roots is not None
|
|
||||||
return workflow_server_from_service(
|
return workflow_server_from_service(
|
||||||
service,
|
service,
|
||||||
config=config,
|
config=config,
|
||||||
|
|||||||
@@ -280,13 +280,13 @@ def test_handler_delegation_for_inspect_artifact(tmp_path: Path) -> None:
|
|||||||
assert handler_result["version"] == api_result["version"]
|
assert handler_result["version"] == api_result["version"]
|
||||||
assert handler_result["title"] == api_result["title"]
|
assert handler_result["title"] == api_result["title"]
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
def test_delete_artifact_deletes_unreferenced_version(tmp_path: Path) -> None:
|
async def test_delete_artifact_deletes_unreferenced_version(tmp_path: Path) -> None:
|
||||||
artifact_store = FileWorkflowArtifactStore(tmp_path / "artifacts_delete")
|
artifact_store = FileWorkflowArtifactStore(tmp_path / "artifacts_delete")
|
||||||
api, _service = _artifact_api(artifact_store)
|
api, _service = _artifact_api(artifact_store)
|
||||||
artifact_store.save_artifact(_echo_artifact())
|
artifact_store.save_artifact(_echo_artifact())
|
||||||
|
|
||||||
result = asyncio.run(api.delete_artifact(artifact_id="echo", version=1))
|
result = await api.delete_artifact(artifact_id="echo", version=1)
|
||||||
|
|
||||||
assert result["artifact_id"] == "echo"
|
assert result["artifact_id"] == "echo"
|
||||||
assert result["version"] == 1
|
assert result["version"] == 1
|
||||||
@@ -295,8 +295,8 @@ def test_delete_artifact_deletes_unreferenced_version(tmp_path: Path) -> None:
|
|||||||
with pytest.raises(KeyError, match="unknown workflow artifact"):
|
with pytest.raises(KeyError, match="unknown workflow artifact"):
|
||||||
artifact_store.get_artifact("echo", 1)
|
artifact_store.get_artifact("echo", 1)
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
def test_delete_artifact_rejects_referenced_version(tmp_path: Path) -> None:
|
async def test_delete_artifact_rejects_referenced_version(tmp_path: Path) -> None:
|
||||||
artifact_store = FileWorkflowArtifactStore(tmp_path / "artifacts_delete_blocked")
|
artifact_store = FileWorkflowArtifactStore(tmp_path / "artifacts_delete_blocked")
|
||||||
api, _service = _artifact_api(artifact_store)
|
api, _service = _artifact_api(artifact_store)
|
||||||
artifact_store.save_artifact(_echo_artifact())
|
artifact_store.save_artifact(_echo_artifact())
|
||||||
@@ -308,7 +308,7 @@ def test_delete_artifact_rejects_referenced_version(tmp_path: Path) -> None:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = asyncio.run(api.delete_artifact(artifact_id="echo", version=1))
|
result = await api.delete_artifact(artifact_id="echo", version=1)
|
||||||
|
|
||||||
assert result["artifact_id"] == "echo"
|
assert result["artifact_id"] == "echo"
|
||||||
assert result["version"] == 1
|
assert result["version"] == 1
|
||||||
|
|||||||
@@ -760,7 +760,7 @@ def test_wf_draft_delete_succeeds_with_confirm(monkeypatch, tmp_path) -> None:
|
|||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
base_args = ["--config", str(config_path), "--url", "http://test/rpc"]
|
base_args = ["--config", str(config_path), "--url", "http://test/rpc"]
|
||||||
|
|
||||||
runner.invoke(
|
created = runner.invoke(
|
||||||
app,
|
app,
|
||||||
[
|
[
|
||||||
*base_args,
|
*base_args,
|
||||||
@@ -772,6 +772,7 @@ def test_wf_draft_delete_succeeds_with_confirm(monkeypatch, tmp_path) -> None:
|
|||||||
"delete_me_ws",
|
"delete_me_ws",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
assert created.exit_code == 0, created.output
|
||||||
|
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
app, [*base_args, "draft", "delete", "delete-me", "--confirm"]
|
app, [*base_args, "draft", "delete", "delete-me", "--confirm"]
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ from wf_api.models import RawWorkflowPlan
|
|||||||
from wf_authoring import node
|
from wf_authoring import node
|
||||||
from wf_core import END
|
from wf_core import END
|
||||||
from wf_mcp.capabilities import DiscoveredTool
|
from wf_mcp.capabilities import DiscoveredTool
|
||||||
from wf_mcp.models import AuthRecord, ConnectionConfig
|
from wf_mcp.models import AuthRecord
|
||||||
from wf_mcp.sdk import ToolCallResult
|
from wf_mcp.sdk import ToolCallResult
|
||||||
|
from wf_sources_mcp import McpSourceConnection
|
||||||
|
|
||||||
from ..test_support import (
|
from ..test_support import (
|
||||||
EchoInput,
|
EchoInput,
|
||||||
@@ -28,7 +29,7 @@ class ContentOnlyOutputAdapter(FakeAdapter):
|
|||||||
|
|
||||||
async def list_tools(
|
async def list_tools(
|
||||||
self,
|
self,
|
||||||
connection: ConnectionConfig,
|
connection: McpSourceConnection,
|
||||||
auth: AuthRecord | None,
|
auth: AuthRecord | None,
|
||||||
) -> list[DiscoveredTool]:
|
) -> list[DiscoveredTool]:
|
||||||
return [
|
return [
|
||||||
@@ -51,7 +52,7 @@ class ContentOnlyOutputAdapter(FakeAdapter):
|
|||||||
|
|
||||||
async def call_tool(
|
async def call_tool(
|
||||||
self,
|
self,
|
||||||
connection: ConnectionConfig,
|
connection: McpSourceConnection,
|
||||||
auth: AuthRecord | None,
|
auth: AuthRecord | None,
|
||||||
tool_name: str,
|
tool_name: str,
|
||||||
payload: dict[str, Any],
|
payload: dict[str, Any],
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from wf_artifacts import (
|
||||||
|
FileDraftWorkspaceStore,
|
||||||
|
FileRunStore,
|
||||||
|
FileWorkflowArtifactStore,
|
||||||
|
)
|
||||||
from wf_config import WorkflowConfigFile
|
from wf_config import WorkflowConfigFile
|
||||||
from wf_mcp.broker.config import broker_config_from_workflow_config
|
from wf_mcp.broker.config import broker_config_from_workflow_config
|
||||||
from wf_mcp.models import CatalogSnapshot
|
from wf_mcp.models import CatalogSnapshot
|
||||||
|
from wf_mcp.storage import FileAuthStore, FileCatalogStore, FileStore
|
||||||
|
|
||||||
|
|
||||||
def test_broker_config_from_workflow_config_converts_mcp_sources(
|
def test_broker_config_from_workflow_config_converts_mcp_sources(
|
||||||
@@ -187,9 +193,13 @@ def test_build_service_from_neutral_config_uses_role_store_roots(
|
|||||||
broker = broker_config_from_workflow_config(config)
|
broker = broker_config_from_workflow_config(config)
|
||||||
service = build_service_from_config(broker)
|
service = build_service_from_config(broker)
|
||||||
|
|
||||||
|
assert isinstance(service.store, FileStore)
|
||||||
|
assert isinstance(service.auth_store, FileAuthStore)
|
||||||
|
assert isinstance(service.catalog_store, FileCatalogStore)
|
||||||
|
assert isinstance(service.artifact_store, FileWorkflowArtifactStore)
|
||||||
|
assert isinstance(service.draft_workspace_store, FileDraftWorkspaceStore)
|
||||||
|
assert isinstance(service.run_store, FileRunStore)
|
||||||
assert service.store.root == tmp_path / "auth"
|
assert service.store.root == tmp_path / "auth"
|
||||||
assert service.auth_store is not None
|
|
||||||
assert service.catalog_store is not None
|
|
||||||
assert service.auth_store.root == tmp_path / "auth"
|
assert service.auth_store.root == tmp_path / "auth"
|
||||||
assert service.catalog_store.root == tmp_path / "catalog"
|
assert service.catalog_store.root == tmp_path / "catalog"
|
||||||
assert service.artifact_store.root == tmp_path / "workflow"
|
assert service.artifact_store.root == tmp_path / "workflow"
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ def _runtime_reuse_server(
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
assert config.store_roots is not None
|
|
||||||
store_roots = config.store_roots
|
store_roots = config.store_roots
|
||||||
workflow_stores = file_workflow_stores(store_roots.workflow_root)
|
workflow_stores = file_workflow_stores(store_roots.workflow_root)
|
||||||
auth_store = FileAuthStore(store_roots.auth_root)
|
auth_store = FileAuthStore(store_roots.auth_root)
|
||||||
|
|||||||
Reference in New Issue
Block a user