code review
This commit is contained in:
@@ -77,6 +77,11 @@ def test_connection_service_sync_removes_retired_connections_and_sources() -> No
|
||||
|
||||
assert service.list_all() == []
|
||||
assert "demo.personal" not in catalog.capability_sources
|
||||
removed = service.events.list_events()[-1]
|
||||
assert removed.kind == "connection_removed"
|
||||
assert removed.connection_id == "demo.personal"
|
||||
assert removed.payload["server"] == "demo"
|
||||
assert removed.payload["account"] == "personal"
|
||||
|
||||
|
||||
def test_connection_service_sync_updates_existing_source_enabled_flag() -> None:
|
||||
@@ -102,6 +107,34 @@ def test_connection_service_sync_updates_existing_source_enabled_flag() -> None:
|
||||
|
||||
assert service.get("demo.personal").enabled is False
|
||||
assert catalog.capability_sources["demo.personal"].enabled is False
|
||||
updated = service.events.list_events()[-1]
|
||||
assert updated.kind == "connection_updated"
|
||||
assert updated.connection_id == "demo.personal"
|
||||
assert updated.payload["enabled"] is False
|
||||
|
||||
|
||||
def test_connection_service_sync_registers_new_connections_with_event() -> None:
|
||||
service = ConnectionService(events=BrokerEventRecorder(EventBus()))
|
||||
catalog = _source_catalog(service)
|
||||
|
||||
service.sync_connections_from_config(
|
||||
BrokerConfig(
|
||||
store_root=local_temp_root(),
|
||||
connections=[
|
||||
ConnectionConfig(
|
||||
id="demo.personal",
|
||||
server="demo",
|
||||
account="personal",
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
assert service.get("demo.personal").account == "personal"
|
||||
assert catalog.capability_sources["demo.personal"].enabled is True
|
||||
registered = service.events.list_events()[-1]
|
||||
assert registered.kind == "connection_registered"
|
||||
assert registered.connection_id == "demo.personal"
|
||||
|
||||
|
||||
def test_wfmcpservice_exposes_connection_registry_from_connection_service() -> None:
|
||||
|
||||
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from wf_mcp.broker.service.content_access import ContentAccessService
|
||||
from wf_mcp.broker.service.connection_service import ConnectionService
|
||||
from wf_mcp.broker.service.events import BrokerEventRecorder
|
||||
@@ -152,8 +154,6 @@ def test_content_access_renders_local_documentation_prompt() -> None:
|
||||
|
||||
|
||||
def test_content_access_raises_on_unknown_resource() -> None:
|
||||
import pytest
|
||||
|
||||
content_access, _ = _make_content_access(
|
||||
store_root="content_access_missing_resource"
|
||||
)
|
||||
|
||||
@@ -127,11 +127,13 @@ def test_upstream_transport_live_diagnostics_report_missing_connection() -> None
|
||||
store=FileStore(local_temp_root() / "upstream_live_missing"),
|
||||
event_sink=lambda event: None,
|
||||
)
|
||||
|
||||
def _raise_missing_connection(connection_id: str) -> ConnectionConfig:
|
||||
raise KeyError(connection_id)
|
||||
|
||||
source_catalog = SourceCatalogService(
|
||||
store=transport.store,
|
||||
connection_lookup=lambda connection_id: (_ for _ in ()).throw(
|
||||
KeyError(connection_id)
|
||||
),
|
||||
connection_lookup=_raise_missing_connection,
|
||||
connection_list_enabled=lambda: [],
|
||||
connection_list_all=lambda: [],
|
||||
tool_executor_for=transport.tool_executor_for,
|
||||
|
||||
Reference in New Issue
Block a user