fix(tests): update drone tests for S144 handler changes (sync branch-aware, checkout auto-create, help text)
This commit is contained in:
@@ -343,15 +343,19 @@ class TestCommitChanges:
|
||||
assert "nothing to commit" in result["stderr"].lower()
|
||||
|
||||
def test_commit_all_stages_first(self, repo_dir: Path) -> None:
|
||||
mock_ruff = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_add = MagicMock(returncode=0, stderr="")
|
||||
mock_diff = MagicMock(returncode=1, stdout="", stderr="")
|
||||
mock_commit = MagicMock(returncode=0, stdout="[main def456] all commit", stderr="")
|
||||
|
||||
branch_dir = repo_dir / "src" / "aipass" / "api"
|
||||
|
||||
with patch(
|
||||
"aipass.drone.apps.handlers.git.commit_handler.subprocess.run",
|
||||
side_effect=[mock_add, mock_diff, mock_commit],
|
||||
with (
|
||||
patch("shutil.which", return_value="/usr/bin/ruff"),
|
||||
patch(
|
||||
"aipass.drone.apps.handlers.git.commit_handler.subprocess.run",
|
||||
side_effect=[mock_ruff, mock_add, mock_diff, mock_commit],
|
||||
),
|
||||
):
|
||||
result = commit_changes("all commit", branch_dir=branch_dir, all_files=True)
|
||||
|
||||
@@ -427,15 +431,16 @@ class TestCheckoutHandler:
|
||||
def test_checkout_git_failure(self, repo_dir: Path) -> None:
|
||||
mock_status = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_checkout = MagicMock(returncode=1, stdout="", stderr="error: pathspec 'main' did not match")
|
||||
mock_create = MagicMock(returncode=0, stdout="Switched to a new branch 'main'", stderr="")
|
||||
|
||||
with patch(
|
||||
"aipass.drone.apps.handlers.git.checkout_handler.subprocess.run",
|
||||
side_effect=[mock_status, mock_checkout],
|
||||
side_effect=[mock_status, mock_checkout, mock_create],
|
||||
):
|
||||
result = checkout_branch("main")
|
||||
|
||||
assert result["exit_code"] == 1
|
||||
assert result["current_branch"] == ""
|
||||
assert result["exit_code"] == 0
|
||||
assert result["current_branch"] == "main"
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
@@ -554,11 +559,11 @@ class TestUpdatedHelp:
|
||||
assert "global" in text.lower()
|
||||
assert "owner" in text.lower()
|
||||
|
||||
def test_help_marks_pr_deprecated(self) -> None:
|
||||
def test_help_marks_pr_legacy(self) -> None:
|
||||
from aipass.drone.apps.modules.git_module import get_help
|
||||
|
||||
text = get_help()
|
||||
assert "deprecated" in text.lower()
|
||||
assert "legacy" in text.lower()
|
||||
|
||||
def test_introspection_includes_new_handlers(self) -> None:
|
||||
from aipass.drone.apps.modules.git_module import get_introspective
|
||||
|
||||
@@ -295,14 +295,14 @@ class TestSyncHandler:
|
||||
registry.write_text("{}", encoding="utf-8")
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
mock_checkout = MagicMock(returncode=0, stdout="Switched to branch 'main'", stderr="")
|
||||
mock_head = MagicMock(returncode=0, stdout="main", stderr="")
|
||||
mock_fetch = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_rev_list = MagicMock(returncode=0, stdout="0\t0\n", stderr="")
|
||||
mock_pull = MagicMock(returncode=0, stdout="Already up to date.", stderr="")
|
||||
|
||||
with patch(
|
||||
"aipass.drone.apps.handlers.git.sync_handler.subprocess.run",
|
||||
side_effect=[mock_checkout, mock_fetch, mock_rev_list, mock_pull],
|
||||
side_effect=[mock_head, mock_fetch, mock_rev_list, mock_pull],
|
||||
):
|
||||
result = sync_main()
|
||||
|
||||
@@ -335,14 +335,14 @@ class TestSyncHandler:
|
||||
registry.write_text("{}", encoding="utf-8")
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
mock_checkout = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_head = MagicMock(returncode=0, stdout="main", stderr="")
|
||||
mock_fetch = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_rev_list = MagicMock(returncode=0, stdout="0\t1\n", stderr="")
|
||||
mock_pull = MagicMock(returncode=1, stdout="", stderr="fatal: unable to access remote")
|
||||
|
||||
with patch(
|
||||
"aipass.drone.apps.handlers.git.sync_handler.subprocess.run",
|
||||
side_effect=[mock_checkout, mock_fetch, mock_rev_list, mock_pull],
|
||||
side_effect=[mock_head, mock_fetch, mock_rev_list, mock_pull],
|
||||
):
|
||||
result = sync_main()
|
||||
|
||||
@@ -658,14 +658,14 @@ class TestGitModuleRouting:
|
||||
registry.write_text("{}", encoding="utf-8")
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
mock_checkout = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_head = MagicMock(returncode=0, stdout="main", stderr="")
|
||||
mock_fetch = MagicMock(returncode=0, stdout="", stderr="")
|
||||
mock_rev_list = MagicMock(returncode=0, stdout="0\t0\n", stderr="")
|
||||
mock_pull = MagicMock(returncode=0, stdout="Already up to date.", stderr="")
|
||||
|
||||
with patch(
|
||||
"aipass.drone.apps.handlers.git.sync_handler.subprocess.run",
|
||||
side_effect=[mock_checkout, mock_fetch, mock_rev_list, mock_pull],
|
||||
side_effect=[mock_head, mock_fetch, mock_rev_list, mock_pull],
|
||||
):
|
||||
result = handle_command("sync")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user