gabriel / musehub public
test_mcp_input_parity_311.py python
52 lines 2.1 KB
Raw
sha256:e0687e443a179fb20c1f886e31396f5a241c22393f93749c5aa43de2e43cc8d2 fix(mcp): MCP write tools follow the REST input rules — Sem… Opus 5.5 patch 1 day ago
1 """MCP write tools enforce the same input rules as REST (#311, #187): SemVer release tags, the full channel set,
2 public|private visibility, label names unique ignoring case."""
3 from __future__ import annotations
4
5 import pytest
6 from sqlalchemy.ext.asyncio import AsyncSession
7
8 from tests.factories import create_repo
9
10
11 @pytest.mark.asyncio
12 async def test_create_release_refuses_a_non_semver_tag(db_session: AsyncSession) -> None:
13 from musehub.services import musehub_releases
14
15 repo = await create_repo(db_session, owner="parity", slug="parity-tags")
16 with pytest.raises(ValueError, match="not SemVer"):
17 await musehub_releases.create_release(db_session, repo_id=str(repo.repo_id), tag="banana", title="t", body="", commit_id=None)
18
19
20 @pytest.mark.asyncio
21 async def test_create_release_accepts_the_rc_channel(db_session: AsyncSession) -> None:
22 from musehub.services import musehub_releases
23
24 repo = await create_repo(db_session, owner="parity", slug="parity-rc")
25 rel = await musehub_releases.create_release(db_session, repo_id=str(repo.repo_id), tag="v1.0.0-rc.1", title="t", body="",
26 commit_id=None, channel="rc")
27 assert rel.channel == "rc"
28
29
30 def test_mcp_release_schema_lists_every_channel() -> None:
31 from musehub.mcp.tools import musehub as tools
32 from musehub.models.musehub import RELEASE_CHANNELS
33
34 import inspect
35 assert '"enum": ["stable", "beta", "alpha", "rc", "nightly"]' in inspect.getsource(tools)
36 assert RELEASE_CHANNELS == {"stable", "beta", "alpha", "rc", "nightly"}
37
38
39 @pytest.mark.asyncio
40 async def test_mcp_create_repo_refuses_unknown_visibility() -> None:
41 from musehub.mcp.write_tools.repos import execute_create_repo
42
43 result = await execute_create_repo(name="x", owner="parity", owner_user_id="parity", visibility="secret")
44 assert not result.ok and result.error_code == "invalid_args"
45
46
47 def test_mcp_label_duplicate_check_ignores_case() -> None:
48 import inspect
49
50 from musehub.mcp.write_tools import labels
51
52 assert "lower(name) = lower(:name)" in inspect.getsource(labels.execute_create_label)
File History 1 commit
sha256:e0687e443a179fb20c1f886e31396f5a241c22393f93749c5aa43de2e43cc8d2 fix(mcp): MCP write tools follow the REST input rules — Sem… Opus 5.5 patch 1 day ago