feat: add PR review and edit tools to CLI and MCP server
This commit is contained in:
@@ -10,6 +10,7 @@ sys.path.insert(0, str(__import__("pathlib").Path(__file__).resolve().parent.par
|
||||
import list_prs # noqa: E402
|
||||
import view_pr # noqa: E402
|
||||
import delete_branch # noqa: E402
|
||||
import edit_pr # noqa: E402
|
||||
|
||||
|
||||
FAKE_CREDS = "Basic dGVzdHVzZXI6dGVzdHBhc3M="
|
||||
@@ -64,5 +65,36 @@ class TestDeleteBranch(unittest.TestCase):
|
||||
delete_branch.main([])
|
||||
|
||||
|
||||
class TestEditPR(unittest.TestCase):
|
||||
|
||||
@patch("edit_pr.api_request")
|
||||
@patch("edit_pr.get_auth_header", return_value=FAKE_CREDS)
|
||||
def test_edit_pr_success(self, _auth, mock_api):
|
||||
mock_api.return_value = {
|
||||
"number": 1,
|
||||
"title": "New Title",
|
||||
"state": "open",
|
||||
"html_url": "http://url1",
|
||||
"base": {"ref": "main"},
|
||||
"body": "New Description"
|
||||
}
|
||||
rc = edit_pr.main(["1", "--title", "New Title", "--body", "New Description"])
|
||||
self.assertEqual(rc, 0)
|
||||
mock_api.assert_called_once()
|
||||
# Verify call payload
|
||||
payload = mock_api.call_args[0][3]
|
||||
self.assertEqual(payload["title"], "New Title")
|
||||
self.assertEqual(payload["body"], "New Description")
|
||||
|
||||
@patch("edit_pr.get_auth_header", return_value=FAKE_CREDS)
|
||||
def test_missing_fields_fails(self, _auth):
|
||||
rc = edit_pr.main(["1"])
|
||||
self.assertEqual(rc, 1)
|
||||
|
||||
def test_missing_pr_number_exits(self):
|
||||
with self.assertRaises(SystemExit):
|
||||
edit_pr.main([])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user