test: merged-commit lookup, scheduled auto-merge cancel and repository transfer answers
This commit is contained in:
1 parent
7dc749d7cd
commit
84fa29e380
2 files changed
+130
-1
No files matched your search
@@ -221,5 +221,75 @@ async def test_pull_request_review_and_merge(
|
||||
assert merged.data["state"] == "closed"
|
||||
readme = await mcp.ok("gitea_repo_get_contents", filepath="greeting.txt", **repo)
|
||||
assert readme.data["path"] == "greeting.txt"
|
||||
|
||||
# The merge commit resolves back to the pull request.
|
||||
merge_sha = merged.data["merge_commit_sha"]
|
||||
by_commit = await mcp.ok("gitea_repo_get_commit_pull_request", sha=merge_sha, **repo)
|
||||
assert by_commit.data["number"] == index
|
||||
|
||||
# Merging it again is refused with the documented status, not silently accepted.
|
||||
again = await mcp.fail(
|
||||
"gitea_pull_merge_pull_request", 405, index=index, body={"do": "merge"}, **repo
|
||||
)
|
||||
assert again.error_kind == "method_not_allowed"
|
||||
assert "already merged" in again.payload["error"]["message"]
|
||||
finally:
|
||||
gitea.api("DELETE", f"/repos/{fresh_repo.owner}/{fresh_repo.name}/collaborators/{reviewer}")
|
||||
|
||||
|
||||
async def test_scheduled_auto_merge_can_be_cancelled(
|
||||
mcp: McpSession, gitea: GiteaInstance, fresh_repo: RepoRef
|
||||
) -> None:
|
||||
"""A required status check that is still pending turns the merge into a scheduled one."""
|
||||
repo = fresh_repo.args
|
||||
await mcp.ok(
|
||||
"gitea_repo_create_branch",
|
||||
status=201,
|
||||
body={"new_branch_name": "feat/auto", "old_branch_name": "main"},
|
||||
**repo,
|
||||
)
|
||||
await mcp.ok(
|
||||
"gitea_repo_create_file",
|
||||
status=201,
|
||||
filepath="auto.txt",
|
||||
body={"content": b64("auto\n"), "message": "add auto", "branch": "feat/auto"},
|
||||
**repo,
|
||||
)
|
||||
await mcp.ok(
|
||||
"gitea_repo_create_branch_protection",
|
||||
status=201,
|
||||
body={
|
||||
"rule_name": "main",
|
||||
"enable_status_check": True,
|
||||
"status_check_contexts": ["ci/required"],
|
||||
},
|
||||
**repo,
|
||||
)
|
||||
pull = await mcp.ok(
|
||||
"gitea_pull_create_pull_request",
|
||||
status=201,
|
||||
body={"title": "Auto merge", "base": "main", "head": "feat/auto"},
|
||||
**repo,
|
||||
)
|
||||
index = pull.data["number"]
|
||||
await mcp.ok(
|
||||
"gitea_repo_create_status",
|
||||
status=201,
|
||||
sha=pull.data["head"]["sha"],
|
||||
body={"state": "pending", "context": "ci/required"},
|
||||
**repo,
|
||||
)
|
||||
scheduled = await mcp.ok(
|
||||
"gitea_pull_merge_pull_request",
|
||||
status=201,
|
||||
index=index,
|
||||
body={"do": "merge", "merge_when_checks_succeed": True},
|
||||
**repo,
|
||||
)
|
||||
assert scheduled.status == 201 # scheduled, not merged
|
||||
assert (await mcp.ok("gitea_pull_get_pull_request", index=index, **repo)).data[
|
||||
"merged"
|
||||
] is False
|
||||
await mcp.ok("gitea_pull_cancel_scheduled_auto_merge", index=index, **repo)
|
||||
# Nothing is scheduled any more.
|
||||
await mcp.fail("gitea_pull_cancel_scheduled_auto_merge", 404, index=index, **repo)
|
||||
Reference in new issue
Block a user