db5a43b19a
Relocate the script into the skill (skills/gitea/scripts/gitea_mcp.py) and add a PEP 723 dependency block, so `uv run scripts/gitea_mcp.py` provisions deps with no install step and the skill folder is portable (drop into ~/.cline/skills/). Drop the non-standard `metadata` frontmatter — Cline only recognizes name + description. - .mcp.json points at the relocated script and runs with --no-project (PEP 723) - SKILL.md uses relative scripts/ paths; metadata block removed - find_config walks up the tree to locate config.json (skill root or plugin root) - tests import gitea_mcp via pytest pythonpath; README/CLAUDE paths updated Tests: 119 passed, 92% coverage. Standalone list-tools verified via uv --no-project.
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
import pytest
|
|
import httpx
|
|
import respx
|
|
from gitea_mcp import list_instances, get_server_info, get_current_user
|
|
|
|
BASE = "https://gitea.test/api/v1"
|
|
|
|
|
|
def test_list_instances():
|
|
result = list_instances()
|
|
assert result["default"] == "default"
|
|
assert "default" in result["instances"]
|
|
|
|
|
|
@respx.mock
|
|
def test_get_server_info():
|
|
route = respx.get(f"{BASE}/version").mock(
|
|
return_value=httpx.Response(200, json={"version": "1.22.0"})
|
|
)
|
|
result = get_server_info()
|
|
assert route.called
|
|
assert result == {"version": "1.22.0"}
|
|
|
|
|
|
@respx.mock
|
|
def test_get_server_info_error():
|
|
respx.get(f"{BASE}/version").mock(return_value=httpx.Response(500, json={"message": "internal error"}))
|
|
with pytest.raises(RuntimeError, match="500"):
|
|
get_server_info()
|
|
|
|
|
|
@respx.mock
|
|
def test_get_current_user():
|
|
route = respx.get(f"{BASE}/user").mock(
|
|
return_value=httpx.Response(200, json={"login": "alice", "id": 1})
|
|
)
|
|
result = get_current_user()
|
|
assert route.called
|
|
assert result["login"] == "alice"
|
|
|
|
|
|
@respx.mock
|
|
def test_get_current_user_error():
|
|
respx.get(f"{BASE}/user").mock(return_value=httpx.Response(401, json={"message": "unauthorized"}))
|
|
with pytest.raises(RuntimeError, match="401"):
|
|
get_current_user()
|