fix: detect Gitea issues with null pull request metadata

This commit is contained in:
2026-05-06 15:46:28 +08:00
parent bd24a18c18
commit 631dc2ce3d
4 changed files with 51 additions and 5 deletions

View File

@@ -89,6 +89,36 @@ def test_sync_and_scan_with_mocked_gitea(db, tmp_path):
assert len(task_ids) == 1
def test_list_open_issues_keeps_normal_issues_with_null_pull_request():
def handler(request: httpx.Request) -> httpx.Response:
assert request.url.path == "/api/v1/repos/acme/service/issues"
return httpx.Response(
200,
json=[
{
"number": 1,
"title": "Normal issue",
"body": "Body",
"state": "open",
"labels": [{"name": "agent:ready"}],
"pull_request": None,
},
{
"number": 2,
"title": "PR issue",
"body": "Body",
"state": "open",
"labels": [{"name": "agent:ready"}],
"pull_request": {"url": "https://gitea.test/pr/2"},
},
],
)
issues = make_client(handler).list_open_issues("acme", "service")
assert [issue.number for issue in issues] == [1]
class FakeWorkspaceManager:
def __init__(self, root: Path, *, diff: bool = True):
self.root = root