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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user