Merge pull request 'Add pagination metadata to gitea_list_prs' (#342) from feat/issue-340-list-prs-pagination-metadata into master
This commit was merged in pull request #342.
This commit is contained in:
+27
-18
@@ -400,40 +400,49 @@ class TestMirrorRefs(unittest.TestCase):
|
||||
# ---------------------------------------------------------------------------
|
||||
class TestListPRs(unittest.TestCase):
|
||||
|
||||
@patch("mcp_server.api_get_all")
|
||||
@patch("mcp_server.api_fetch_page")
|
||||
@patch("mcp_server.get_auth_header", return_value=FAKE_AUTH)
|
||||
def test_list_prs(self, _auth, mock_api):
|
||||
mock_api.return_value = [
|
||||
{
|
||||
def test_list_prs(self, _auth, mock_fetch):
|
||||
mock_fetch.return_value = (
|
||||
[{
|
||||
"number": 1, "title": "PR 1", "state": "open",
|
||||
"head": {"ref": "branch1"}, "base": {"ref": "main"},
|
||||
"html_url": "http://url1", "mergeable": True,
|
||||
"updated_at": "2026-07-05T12:00:00Z"
|
||||
}
|
||||
]
|
||||
}],
|
||||
{
|
||||
"page": 1, "per_page": 50, "returned_count": 1,
|
||||
"has_more": False, "next_page": None, "is_final_page": True,
|
||||
},
|
||||
)
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
result = gitea_list_prs()
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertEqual(result[0]["number"], 1)
|
||||
self.assertEqual(result[0]["head"], "branch1")
|
||||
self.assertNotIn("url", result[0])
|
||||
self.assertEqual(len(result["prs"]), 1)
|
||||
self.assertEqual(result["prs"][0]["number"], 1)
|
||||
self.assertEqual(result["prs"][0]["head"], "branch1")
|
||||
self.assertNotIn("url", result["prs"][0])
|
||||
self.assertTrue(result["pagination"]["inventory_complete"])
|
||||
# Staleness fields for queue reconciliation (#166)
|
||||
self.assertEqual(result[0]["updated_at"], "2026-07-05T12:00:00Z")
|
||||
self.assertEqual(result["prs"][0]["updated_at"], "2026-07-05T12:00:00Z")
|
||||
|
||||
@patch("mcp_server.api_get_all")
|
||||
@patch("mcp_server.api_fetch_page")
|
||||
@patch("mcp_server.get_auth_header", return_value=FAKE_AUTH)
|
||||
def test_list_prs_reveal_opt_in_includes_url(self, _auth, mock_api):
|
||||
mock_api.return_value = [
|
||||
{
|
||||
def test_list_prs_reveal_opt_in_includes_url(self, _auth, mock_fetch):
|
||||
mock_fetch.return_value = (
|
||||
[{
|
||||
"number": 1, "title": "PR 1", "state": "open",
|
||||
"head": {"ref": "branch1"}, "base": {"ref": "main"},
|
||||
"html_url": "http://url1", "mergeable": True,
|
||||
"updated_at": "2026-07-05T12:00:00Z"
|
||||
}
|
||||
]
|
||||
}],
|
||||
{
|
||||
"page": 1, "per_page": 50, "returned_count": 1,
|
||||
"has_more": False, "next_page": None, "is_final_page": True,
|
||||
},
|
||||
)
|
||||
with patch.dict(os.environ, {"GITEA_MCP_REVEAL_ENDPOINTS": "1"}, clear=True):
|
||||
result = gitea_list_prs()
|
||||
self.assertEqual(result[0]["url"], "http://url1")
|
||||
self.assertEqual(result["prs"][0]["url"], "http://url1")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user