gpt-5.2: fix tests and imports after git queries split
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / lint-shell (push) Has been cancelled
Mark stable commit / lint-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / lint-shell (push) Has been cancelled
Mark stable commit / lint-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
https://chatgpt.com/share/694135eb-10a8-800f-8b12-968612f605c7 Gemini https://ai.studio/apps/drive/1QO9MaEklm2zZMDZ6XPP0LStuAooXs1NO
This commit is contained in:
@@ -7,7 +7,7 @@ from pkgmgr.core.git.commands import GitDeleteRemoteBranchError
|
||||
|
||||
|
||||
class TestCloseBranch(unittest.TestCase):
|
||||
@patch("pkgmgr.actions.branch.close_branch.input", return_value="y")
|
||||
@patch("builtins.input", return_value="y")
|
||||
@patch("pkgmgr.actions.branch.close_branch.get_current_branch", return_value="feature-x")
|
||||
@patch("pkgmgr.actions.branch.close_branch.resolve_base_branch", return_value="main")
|
||||
@patch("pkgmgr.actions.branch.close_branch.fetch")
|
||||
@@ -26,10 +26,10 @@ class TestCloseBranch(unittest.TestCase):
|
||||
pull,
|
||||
checkout,
|
||||
fetch,
|
||||
resolve,
|
||||
current,
|
||||
input_mock,
|
||||
):
|
||||
_resolve,
|
||||
_current,
|
||||
_input_mock,
|
||||
) -> None:
|
||||
close_branch(None, cwd=".")
|
||||
fetch.assert_called_once_with("origin", cwd=".")
|
||||
checkout.assert_called_once_with("main", cwd=".")
|
||||
@@ -41,31 +41,61 @@ class TestCloseBranch(unittest.TestCase):
|
||||
|
||||
@patch("pkgmgr.actions.branch.close_branch.get_current_branch", return_value="main")
|
||||
@patch("pkgmgr.actions.branch.close_branch.resolve_base_branch", return_value="main")
|
||||
def test_refuses_to_close_base_branch(self, resolve, current):
|
||||
def test_refuses_to_close_base_branch(self, _resolve, _current) -> None:
|
||||
with self.assertRaises(RuntimeError):
|
||||
close_branch(None)
|
||||
|
||||
@patch("pkgmgr.actions.branch.close_branch.input", return_value="n")
|
||||
@patch("builtins.input", return_value="n")
|
||||
@patch("pkgmgr.actions.branch.close_branch.get_current_branch", return_value="feature-x")
|
||||
@patch("pkgmgr.actions.branch.close_branch.resolve_base_branch", return_value="main")
|
||||
@patch("pkgmgr.actions.branch.close_branch.fetch")
|
||||
def test_close_branch_aborts_on_no(self, fetch, resolve, current, input_mock):
|
||||
def test_close_branch_aborts_on_no(self, fetch, _resolve, _current, _input_mock) -> None:
|
||||
close_branch(None, cwd=".")
|
||||
fetch.assert_not_called()
|
||||
|
||||
@patch("builtins.input")
|
||||
@patch("pkgmgr.actions.branch.close_branch.get_current_branch", return_value="feature-x")
|
||||
@patch("pkgmgr.actions.branch.close_branch.resolve_base_branch", return_value="main")
|
||||
@patch("pkgmgr.actions.branch.close_branch.fetch")
|
||||
def test_close_branch_force_skips_prompt(self, fetch, resolve, current):
|
||||
@patch("pkgmgr.actions.branch.close_branch.checkout")
|
||||
@patch("pkgmgr.actions.branch.close_branch.pull")
|
||||
@patch("pkgmgr.actions.branch.close_branch.merge_no_ff")
|
||||
@patch("pkgmgr.actions.branch.close_branch.push")
|
||||
@patch("pkgmgr.actions.branch.close_branch.delete_local_branch")
|
||||
@patch("pkgmgr.actions.branch.close_branch.delete_remote_branch")
|
||||
def test_close_branch_force_skips_prompt(
|
||||
self,
|
||||
delete_remote_branch,
|
||||
delete_local_branch,
|
||||
push,
|
||||
merge_no_ff,
|
||||
pull,
|
||||
checkout,
|
||||
fetch,
|
||||
_resolve,
|
||||
_current,
|
||||
input_mock,
|
||||
) -> None:
|
||||
close_branch(None, cwd=".", force=True)
|
||||
fetch.assert_called_once()
|
||||
|
||||
# no interactive prompt when forced
|
||||
input_mock.assert_not_called()
|
||||
|
||||
# workflow still runs (but is mocked)
|
||||
fetch.assert_called_once_with("origin", cwd=".")
|
||||
checkout.assert_called_once_with("main", cwd=".")
|
||||
pull.assert_called_once_with("origin", "main", cwd=".")
|
||||
merge_no_ff.assert_called_once_with("feature-x", cwd=".")
|
||||
push.assert_called_once_with("origin", "main", cwd=".")
|
||||
delete_local_branch.assert_called_once_with("feature-x", cwd=".", force=False)
|
||||
delete_remote_branch.assert_called_once_with("origin", "feature-x", cwd=".")
|
||||
|
||||
@patch("pkgmgr.actions.branch.close_branch.get_current_branch", side_effect=GitError("fail"))
|
||||
def test_close_branch_errors_if_cannot_detect_branch(self, current):
|
||||
def test_close_branch_errors_if_cannot_detect_branch(self, _current) -> None:
|
||||
with self.assertRaises(RuntimeError):
|
||||
close_branch(None)
|
||||
|
||||
@patch("pkgmgr.actions.branch.close_branch.input", return_value="y")
|
||||
@patch("builtins.input", return_value="y")
|
||||
@patch("pkgmgr.actions.branch.close_branch.get_current_branch", return_value="feature-x")
|
||||
@patch("pkgmgr.actions.branch.close_branch.resolve_base_branch", return_value="main")
|
||||
@patch("pkgmgr.actions.branch.close_branch.fetch")
|
||||
@@ -80,17 +110,17 @@ class TestCloseBranch(unittest.TestCase):
|
||||
)
|
||||
def test_close_branch_remote_delete_failure_is_wrapped(
|
||||
self,
|
||||
delete_remote_branch,
|
||||
delete_local_branch,
|
||||
push,
|
||||
merge_no_ff,
|
||||
pull,
|
||||
checkout,
|
||||
fetch,
|
||||
resolve,
|
||||
current,
|
||||
input_mock,
|
||||
):
|
||||
_delete_remote_branch,
|
||||
_delete_local_branch,
|
||||
_push,
|
||||
_merge_no_ff,
|
||||
_pull,
|
||||
_checkout,
|
||||
_fetch,
|
||||
_resolve,
|
||||
_current,
|
||||
_input_mock,
|
||||
) -> None:
|
||||
with self.assertRaises(RuntimeError) as ctx:
|
||||
close_branch(None, cwd=".")
|
||||
self.assertIn("remote deletion failed", str(ctx.exception))
|
||||
|
||||
Reference in New Issue
Block a user