refactor: move mcp adapter helper to wf_sources_mcp

This commit is contained in:
lda
2026-06-08 11:18:56 +07:00 Verified
parent ec3414c1cb
commit 8cab3bcf10
10 changed files with 820 additions and 17 deletions
@@ -196,3 +196,26 @@ def test_wf_sources_mcp_does_not_import_old_broker_event_modules() -> None:
"wf_sources_mcp still imports old wf_mcp broker event modules:\n"
+ "\n".join(f" {violation}" for violation in violations)
)
def test_wf_sources_mcp_does_not_import_old_broker_service_adapter_module() -> None:
root = Path(__file__).resolve().parents[2] / "src" / "wf_sources_mcp"
forbidden = {"wf_mcp.broker.service.adapters"}
violations: list[str] = []
for py_file in sorted(root.rglob("*.py")):
rel = py_file.relative_to(root.parent)
module = str(rel.with_suffix("")).replace("/", ".").replace("\\", ".")
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 in forbidden:
violations.append(f"{module}:{node.lineno}: from {node.module} import ...")
elif isinstance(node, ast.Import):
for alias in node.names:
if alias.name in forbidden:
violations.append(f"{module}:{node.lineno}: import {alias.name}")
assert violations == [], (
"wf_sources_mcp still imports old wf_mcp broker service adapter module:\n"
+ "\n".join(f" {violation}" for violation in violations)
)