gabriel / musehub public
test_mcp_release_interactive_url_client.py python
54 lines 2.5 KB
Raw
sha256:3d28011408500b3b8512a46e00261fcbb9f2c0ef7a6910e651802fef1086f0e9 fix(mcp): interactive release no longer crashes for URL-cap… Opus 5.5 minor ⚠ breaking 1 day ago
1 """musehub_create_release_interactive with a client that supports URL elicitation, and the release tool schema.
2
3 Before, the elicitation path ended by offering a "connect Spotify" URL through ``oauth_connect_url``, a name defined
4 nowhere: every URL-capable client got a ``NameError`` after the release had already been created. There is no
5 platform-connection backend, so the tool now ends once the release exists.
6 """
7 from __future__ import annotations
8
9 import asyncio
10
11 import pytest
12
13 from musehub.mcp import session
14 from musehub.mcp.context import ToolCallContext
15 from musehub.mcp.tools.musehub import MUSEHUB_TOOLS
16 from musehub.mcp.write_tools import elicitation_tools, releases
17 from musehub.services.musehub_mcp_executor import MusehubToolResult
18
19
20 def test_a_url_capable_client_gets_the_created_release(monkeypatch: pytest.MonkeyPatch) -> None:
21 async def _create(**kw: object) -> MusehubToolResult:
22 return MusehubToolResult(ok=True, data={"tag": kw["tag"], "channel": kw["channel"]})
23
24 async def _form(self: ToolCallContext, schema: object, message: str) -> dict:
25 return {"tag": "v1.2.0", "title": "One two", "channel": "rc"}
26
27 async def _url(self: ToolCallContext, *a: object, **k: object) -> bool:
28 raise AssertionError("no URL elicitation is offered: there is no platform-connection backend")
29
30 monkeypatch.setattr(releases, "execute_create_release", _create)
31 monkeypatch.setattr(ToolCallContext, "elicit_form", _form)
32 monkeypatch.setattr(ToolCallContext, "elicit_url", _url)
33 sess = session.create_session("u", {"elicitation": {"form": {}, "url": {}}})
34 try:
35 result = asyncio.run(elicitation_tools.execute_create_release_interactive("repo", ctx=ToolCallContext("u", sess)))
36 finally:
37 session.delete_session(sess.session_id)
38 assert result.ok, result.error_message
39 assert result.data and result.data["tag"] == "v1.2.0" and result.data["channel"] == "rc"
40
41
42 def _tool(name: str) -> dict:
43 return next(t for t in MUSEHUB_TOOLS if t["name"] == name)
44
45
46 def test_create_release_schema_offers_channel_not_is_prerelease() -> None:
47 props = _tool("musehub_create_release")["inputSchema"]["properties"]
48 assert "is_prerelease" not in props, "the dispatcher never reads is_prerelease; channel decides the tier"
49 assert props["channel"]["enum"] == ["stable", "beta", "alpha", "rc", "nightly"]
50
51
52 def test_interactive_release_description_promises_no_platform_connection() -> None:
53 desc = _tool("musehub_create_release_interactive")["description"]
54 assert "OAuth" not in desc and "URL-mode" not in desc
File History 1 commit
sha256:3d28011408500b3b8512a46e00261fcbb9f2c0ef7a6910e651802fef1086f0e9 fix(mcp): interactive release no longer crashes for URL-cap… Opus 5.5 minor ⚠ 1 day ago