Initial curated ITWorx_MCP_Hub source from 368fba691ea8d23403b4d56b53b5ec670d7c5020
This commit is contained in:
commit
cb5be898ea
663 files changed
+82674
No files matched your search
@@ -0,0 +1,90 @@
|
||||
"""Regression tests for pull-request exact-head validation fallback."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from uuid import UUID
|
||||
|
||||
import httpx
|
||||
|
||||
from packages.connector_kit import (
|
||||
GiteaClient,
|
||||
GiteaSettings,
|
||||
RegisteredRepository,
|
||||
StaticTokenProvider,
|
||||
)
|
||||
|
||||
HEAD_SHA = "e" * 40
|
||||
|
||||
|
||||
def _client(statuses: list[dict[str, str]]) -> tuple[GiteaClient, RegisteredRepository]:
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
if request.url.path.endswith("/actions/runs"):
|
||||
return httpx.Response(200, json={"workflow_runs": []}, request=request)
|
||||
if "/branches/" in request.url.path:
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={"name": "codex/workflows", "commit": {"id": HEAD_SHA}},
|
||||
request=request,
|
||||
)
|
||||
if request.url.path.endswith(f"/commits/{HEAD_SHA}/statuses"):
|
||||
return httpx.Response(200, json=statuses, request=request)
|
||||
return httpx.Response(404, json={"message": "not found"}, request=request)
|
||||
|
||||
settings = GiteaSettings(
|
||||
base_url="https://gitea.example",
|
||||
token_reference="docker-secret://gitea-token", # noqa: S106
|
||||
)
|
||||
client = GiteaClient(
|
||||
settings,
|
||||
StaticTokenProvider("fixture-token"),
|
||||
transport=httpx.MockTransport(handler),
|
||||
)
|
||||
repository = RegisteredRepository(
|
||||
repository_ref="hub",
|
||||
project_id=UUID("11111111-1111-1111-1111-111111111111"),
|
||||
owner="acme",
|
||||
name="hub",
|
||||
source_uri="itworx-git://hub/hub",
|
||||
private=True,
|
||||
)
|
||||
return client, repository
|
||||
|
||||
|
||||
def test_exact_head_status_fallback_treats_skipped_contexts_as_neutral() -> None:
|
||||
client, repository = _client(
|
||||
[
|
||||
{"context": "required", "status": "success", "created_at": "2026-08-27T04:00:02Z"},
|
||||
{
|
||||
"context": "not-applicable",
|
||||
"status": "skipped",
|
||||
"created_at": "2026-08-27T04:00:01Z",
|
||||
},
|
||||
]
|
||||
)
|
||||
try:
|
||||
runs = client.action_runs(repository, branch="codex/workflows", page=1, limit=25)
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
assert len(runs) == 1
|
||||
assert runs[0]["head_sha"] == HEAD_SHA
|
||||
assert runs[0]["conclusion"] == "success"
|
||||
assert runs[0]["validation_evidence"] == "commit-statuses"
|
||||
|
||||
|
||||
def test_exact_head_status_fallback_rejects_pending_or_failed_contexts() -> None:
|
||||
for blocked_state in ("pending", "failure"):
|
||||
client, repository = _client(
|
||||
[
|
||||
{"context": "required", "status": "success", "created_at": "2026-08-27T04:00:02Z"},
|
||||
{
|
||||
"context": "blocked",
|
||||
"status": blocked_state,
|
||||
"created_at": "2026-08-27T04:00:01Z",
|
||||
},
|
||||
]
|
||||
)
|
||||
try:
|
||||
assert client.action_runs(repository, branch="codex/workflows", page=1, limit=25) == []
|
||||
finally:
|
||||
client.close()
|
||||
Reference in new issue
Block a user