chore: address coderabbit cleanup notes
This commit is contained in:
@@ -93,7 +93,9 @@ def test_list_pagination() -> None:
|
||||
)
|
||||
|
||||
first = asyncio.run(api.list_registry_entries(limit=2))
|
||||
second = asyncio.run(api.list_registry_entries(cursor=first["next_cursor"], limit=2))
|
||||
second = asyncio.run(
|
||||
api.list_registry_entries(cursor=first["next_cursor"], limit=2)
|
||||
)
|
||||
|
||||
assert [e["id"] for e in first["entries"]] == ["a", "b"]
|
||||
assert first["next_cursor"] == "2"
|
||||
@@ -162,7 +164,9 @@ class FakeMutationProvider:
|
||||
self._entries.append(fe)
|
||||
return asdict(fe)
|
||||
|
||||
def update_registry_entry(self, source_id: str, patch: Mapping[str, Any]) -> dict[str, Any]:
|
||||
def update_registry_entry(
|
||||
self, source_id: str, patch: Mapping[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
for i, e in enumerate(self._entries):
|
||||
if e.id == source_id:
|
||||
merged = asdict(e)
|
||||
@@ -171,7 +175,9 @@ class FakeMutationProvider:
|
||||
return merged
|
||||
raise KeyError(source_id)
|
||||
|
||||
def set_registry_entry_enabled(self, source_id: str, enabled: bool) -> dict[str, Any]:
|
||||
def set_registry_entry_enabled(
|
||||
self, source_id: str, enabled: bool
|
||||
) -> dict[str, Any]:
|
||||
for i, e in enumerate(self._entries):
|
||||
if e.id == source_id:
|
||||
merged = asdict(e)
|
||||
@@ -193,12 +199,23 @@ def _mutation_api(
|
||||
) -> tuple[WorkflowSourceRegistryApi, FakeMutationProvider]:
|
||||
provider = FakeRegistryProvider(list(entries) if entries else [], config_ids)
|
||||
mutation = FakeMutationProvider(list(entries) if entries else [])
|
||||
return WorkflowSourceRegistryApi(provider=provider, mutation_provider=mutation), mutation
|
||||
return WorkflowSourceRegistryApi(
|
||||
provider=provider, mutation_provider=mutation
|
||||
), mutation
|
||||
|
||||
|
||||
def test_add_registry_entry() -> None:
|
||||
api, _ = _mutation_api()
|
||||
new_entry = {"id": "new.source", "kind": "mcp", "enabled": True, "provider": "new", "account": "default", "profile": None, "transport": {"kind": "stdio"}, "auth_ref": None}
|
||||
new_entry = {
|
||||
"id": "new.source",
|
||||
"kind": "mcp",
|
||||
"enabled": True,
|
||||
"provider": "new",
|
||||
"account": "default",
|
||||
"profile": None,
|
||||
"transport": {"kind": "stdio"},
|
||||
"auth_ref": None,
|
||||
}
|
||||
payload = asyncio.run(api.add_registry_entry(entry=new_entry))
|
||||
|
||||
assert payload["entry"]["id"] == "new.source"
|
||||
@@ -208,7 +225,16 @@ def test_add_registry_entry() -> None:
|
||||
|
||||
def test_add_registry_entry_shadowed() -> None:
|
||||
api, _ = _mutation_api(config_ids={"new.source"})
|
||||
new_entry = {"id": "new.source", "kind": "mcp", "enabled": True, "provider": "new", "account": "default", "profile": None, "transport": {"kind": "stdio"}, "auth_ref": None}
|
||||
new_entry = {
|
||||
"id": "new.source",
|
||||
"kind": "mcp",
|
||||
"enabled": True,
|
||||
"provider": "new",
|
||||
"account": "default",
|
||||
"profile": None,
|
||||
"transport": {"kind": "stdio"},
|
||||
"auth_ref": None,
|
||||
}
|
||||
payload = asyncio.run(api.add_registry_entry(entry=new_entry))
|
||||
|
||||
assert payload["entry"]["id"] == "new.source"
|
||||
@@ -219,7 +245,9 @@ def test_update_registry_entry() -> None:
|
||||
api, _ = _mutation_api(
|
||||
entries=[FakeRegistryEntry(id="upd.source", provider="old")],
|
||||
)
|
||||
payload = asyncio.run(api.update_registry_entry(source_id="upd.source", patch={"provider": "new"}))
|
||||
payload = asyncio.run(
|
||||
api.update_registry_entry(source_id="upd.source", patch={"provider": "new"})
|
||||
)
|
||||
|
||||
assert payload["entry"]["id"] == "upd.source"
|
||||
assert payload["entry"]["provider"] == "new"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
@@ -113,7 +114,7 @@ def test_workflow_config_rejects_unwired_stdlib_source_id() -> None:
|
||||
|
||||
|
||||
def test_load_workflow_config_resolves_filesystem_store_relative_to_config(
|
||||
tmp_path,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
config_path = tmp_path / "wf.json"
|
||||
config_path.write_text(
|
||||
@@ -133,7 +134,9 @@ def test_load_workflow_config_resolves_filesystem_store_relative_to_config(
|
||||
assert config.server.store.root == (tmp_path / ".wf_store").resolve()
|
||||
|
||||
|
||||
def test_load_workflow_config_preserves_absolute_filesystem_store(tmp_path) -> None:
|
||||
def test_load_workflow_config_preserves_absolute_filesystem_store(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
absolute_root = (tmp_path / "absolute-store").resolve()
|
||||
config_path = tmp_path / "wf.json"
|
||||
config_path.write_text(
|
||||
|
||||
@@ -214,9 +214,7 @@ def test_server_reload_preserves_source_registry_connections() -> None:
|
||||
client = create_server_client(config, config_path=config_path)
|
||||
async with client:
|
||||
before = await client.call_tool("wf.admin.list_sources", {"limit": 100})
|
||||
before_ids = {
|
||||
source["id"] for source in structured(before)["sources"]
|
||||
}
|
||||
before_ids = {source["id"] for source in structured(before)["sources"]}
|
||||
assert "fixture.registry" in before_ids
|
||||
|
||||
await client.call_tool("wf.admin.reload_config")
|
||||
|
||||
@@ -241,7 +241,9 @@ def test_connection_service_sync_config_shadows_registry_entry() -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_connection_service_sync_registry_disabled_entry_hydrates_disabled_source() -> None:
|
||||
def test_connection_service_sync_registry_disabled_entry_hydrates_disabled_source() -> (
|
||||
None
|
||||
):
|
||||
service = ConnectionService(events=BrokerEventRecorder(EventBus()))
|
||||
catalog = _source_catalog(service)
|
||||
store = FileSourceRegistryStore(local_temp_root() / "registry_disabled")
|
||||
|
||||
@@ -14,13 +14,17 @@ from wf_mcp.source_registry import (
|
||||
)
|
||||
|
||||
|
||||
def _store_with_entries(root: Path, *entries: McpSourceRegistryEntry) -> FileSourceRegistryStore:
|
||||
def _store_with_entries(
|
||||
root: Path, *entries: McpSourceRegistryEntry
|
||||
) -> FileSourceRegistryStore:
|
||||
store = FileSourceRegistryStore(root)
|
||||
store.save_registry(SourceRegistryFile(sources=list(entries)))
|
||||
return store
|
||||
|
||||
|
||||
def _entry(source_id: str, *, provider: str = "github", account: str = "work") -> McpSourceRegistryEntry:
|
||||
def _entry(
|
||||
source_id: str, *, provider: str = "github", account: str = "work"
|
||||
) -> McpSourceRegistryEntry:
|
||||
return McpSourceRegistryEntry(
|
||||
id=source_id,
|
||||
provider=provider,
|
||||
@@ -29,7 +33,9 @@ def _entry(source_id: str, *, provider: str = "github", account: str = "work") -
|
||||
)
|
||||
|
||||
|
||||
def _entry_dict(source_id: str, *, provider: str = "github", account: str = "work") -> dict:
|
||||
def _entry_dict(
|
||||
source_id: str, *, provider: str = "github", account: str = "work"
|
||||
) -> dict:
|
||||
return {
|
||||
"id": source_id,
|
||||
"provider": provider,
|
||||
@@ -44,8 +50,13 @@ def _provider(
|
||||
config_ids: frozenset[str] | None = None,
|
||||
) -> SourceRegistryAdminProvider:
|
||||
store = _store_with_entries(tmp_path / "reg", *(entries or []))
|
||||
connections = [ConnectionConfig(id=cid, server="s", account="a") for cid in (config_ids or frozenset())]
|
||||
return SourceRegistryAdminProvider(source_registry_store=store, config_connections=connections)
|
||||
connections = [
|
||||
ConnectionConfig(id=cid, server="s", account="a")
|
||||
for cid in (config_ids or frozenset())
|
||||
]
|
||||
return SourceRegistryAdminProvider(
|
||||
source_registry_store=store, config_connections=connections
|
||||
)
|
||||
|
||||
|
||||
# -- read tests ------------------------------------------------------------
|
||||
@@ -197,7 +208,9 @@ def test_enable_disable_missing_source_raises_key_error(tmp_path: Path) -> None:
|
||||
|
||||
|
||||
def test_remove_persists_absence_and_does_not_touch_unrelated(tmp_path: Path) -> None:
|
||||
provider = _provider(tmp_path, entries=[_entry("keep.server"), _entry("drop.server")])
|
||||
provider = _provider(
|
||||
tmp_path, entries=[_entry("keep.server"), _entry("drop.server")]
|
||||
)
|
||||
|
||||
result = provider.remove_registry_entry("drop.server")
|
||||
|
||||
|
||||
@@ -6,11 +6,14 @@ from pathlib import Path
|
||||
|
||||
def test_rpc_transport_has_domain_method_modules() -> None:
|
||||
for module_name in (
|
||||
"wf_transport_rpc_http.methods_admin",
|
||||
"wf_transport_rpc_http.methods_capabilities",
|
||||
"wf_transport_rpc_http.methods_drafts",
|
||||
"wf_transport_rpc_http.methods_artifacts",
|
||||
"wf_transport_rpc_http.methods_deployments",
|
||||
"wf_transport_rpc_http.methods_runs",
|
||||
"wf_transport_rpc_http.methods_sources",
|
||||
"wf_transport_rpc_http.methods_source_registry",
|
||||
):
|
||||
module = importlib.import_module(module_name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user