test: add 106 unit + smoke tests, 93% coverage

- pytest + respx + pytest-cov added as dev dependencies
- tests/smoke/test_registration.py: verify all 66 tools registered and unique
- tests/unit/: 12 files covering every tool — HTTP method, URL, params/body, errors
- tests/config.test.json + conftest.py: zero-network test setup via GITEA_CONFIG
- CLAUDE.md: developer guide with testing philosophy, pyramid, and commands
- server/gitea_mcp.py: get_commit, list_pr_files tools added
- README.md: tool count corrected to 66
This commit is contained in:
2026-06-08 09:09:44 +03:00
parent 50cd8e85e6
commit a6162a855c
23 changed files with 1722 additions and 4 deletions
+24
View File
@@ -484,6 +484,19 @@ def get_pr_diff(owner: str, repo: str, index: int, instance: str = "") -> Any:
raise RuntimeError(f"Gitea API {r.status_code}: {r.text}")
return {"diff": r.text}
@mcp.tool()
def list_pr_files(
owner: str, repo: str, index: int,
limit: int = 50, page: int = 1,
whitespace: str = "",
instance: str = "",
) -> Any:
"""List files changed in a pull request. whitespace: ignore-all|ignore-change|ignore-eol|show-all."""
return GET(instance, f"/repos/{owner}/{repo}/pulls/{index}/files", _strip({
"limit": limit, "page": page,
"whitespace": whitespace or None,
}))
@mcp.tool()
def list_pr_reviews(owner: str, repo: str, index: int, instance: str = "") -> Any:
"""List reviews on a pull request."""
@@ -617,6 +630,17 @@ def list_commits(
"limit": limit, "page": page,
}))
@mcp.tool()
def get_commit(
owner: str, repo: str, sha: str,
stat: bool = True, files: bool = True, verification: bool = False,
instance: str = "",
) -> Any:
"""Get a single commit by SHA or ref. stat=True includes diff stats, files=True includes changed files list."""
return GET(instance, f"/repos/{owner}/{repo}/git/commits/{_b(sha)}", _strip({
"stat": stat, "files": files, "verification": verification or None,
}))
@mcp.tool()
def compare_branches(owner: str, repo: str, base: str, head: str, instance: str = "") -> Any:
"""Compare two branches, tags, or commits."""