feat(test): unit tests — HTTP contract for every tool #17

Closed
opened 2026-06-08 05:41:48 +00:00 by a-limasov · 0 comments
Owner

Goal

For every tool in server/gitea_mcp.py, assert:

  1. Correct HTTP method and URL
  2. Correct query params / request body
  3. Non-2xx response raises RuntimeError with status code

Depends on #15 (infrastructure).

Scope

One test file per category (matches CLAUDE.md layout):

File Tools covered
test_meta.py list_instances, get_server_info, get_current_user
test_repos.py list_my_repos, search_repos, get_repo, create_repo, create_org_repo, update_repo, delete_repo, fork_repo, set_repo_topics
test_branches.py list_branches, get_branch, create_branch, delete_branch, list_tags
test_files.py list_directory, get_file, create_file, update_file, delete_file
test_issues.py list_issues, get_issue, create_issue, update_issue, close_issue, reopen_issue, list_issue_comments, add_issue_comment, edit_issue_comment, delete_issue_comment
test_labels_milestones.py list_labels, create_label, add_issue_labels, list_milestones, create_milestone
test_pull_requests.py list_pull_requests, get_pull_request, create_pull_request, update_pull_request, merge_pull_request, get_pr_diff, list_pr_files, list_pr_reviews, create_pr_review
test_releases.py list_releases, get_latest_release, create_release, delete_release
test_webhooks.py list_repo_webhooks, create_repo_webhook, delete_repo_webhook
test_users_orgs.py get_user, search_users, list_my_orgs, get_org, list_org_repos, list_org_members, list_org_teams
test_commits.py list_commits, get_commit, compare_branches, list_repo_contributors
test_notifications.py list_notifications, mark_all_notifications_read

Acceptance criteria

  • uv run pytest tests/unit/ -v passes
  • uv run pytest --cov=server --cov-report=term-missing shows ≥ 90 % line coverage on server/gitea_mcp.py
  • No real network calls (respx raises if an unmocked URL is hit)
## Goal For every tool in `server/gitea_mcp.py`, assert: 1. Correct HTTP method and URL 2. Correct query params / request body 3. Non-2xx response raises `RuntimeError` with status code Depends on #15 (infrastructure). ## Scope One test file per category (matches `CLAUDE.md` layout): | File | Tools covered | |------|---------------| | `test_meta.py` | list_instances, get_server_info, get_current_user | | `test_repos.py` | list_my_repos, search_repos, get_repo, create_repo, create_org_repo, update_repo, delete_repo, fork_repo, set_repo_topics | | `test_branches.py` | list_branches, get_branch, create_branch, delete_branch, list_tags | | `test_files.py` | list_directory, get_file, create_file, update_file, delete_file | | `test_issues.py` | list_issues, get_issue, create_issue, update_issue, close_issue, reopen_issue, list_issue_comments, add_issue_comment, edit_issue_comment, delete_issue_comment | | `test_labels_milestones.py` | list_labels, create_label, add_issue_labels, list_milestones, create_milestone | | `test_pull_requests.py` | list_pull_requests, get_pull_request, create_pull_request, update_pull_request, merge_pull_request, get_pr_diff, list_pr_files, list_pr_reviews, create_pr_review | | `test_releases.py` | list_releases, get_latest_release, create_release, delete_release | | `test_webhooks.py` | list_repo_webhooks, create_repo_webhook, delete_repo_webhook | | `test_users_orgs.py` | get_user, search_users, list_my_orgs, get_org, list_org_repos, list_org_members, list_org_teams | | `test_commits.py` | list_commits, get_commit, compare_branches, list_repo_contributors | | `test_notifications.py` | list_notifications, mark_all_notifications_read | ## Acceptance criteria - `uv run pytest tests/unit/ -v` passes - `uv run pytest --cov=server --cov-report=term-missing` shows ≥ 90 % line coverage on `server/gitea_mcp.py` - No real network calls (respx raises if an unmocked URL is hit)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: a-limasov/gitea-platform-mcp#17