executet 'ruff format --check .'
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
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
This commit is contained in:
155 files changed
+1327
-636
No files matched your search
@@ -1,4 +1,3 @@
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
@@ -101,9 +101,7 @@ class TestReleaseCommand(unittest.TestCase):
|
||||
handle_release(args, ctx, selected)
|
||||
|
||||
# We should have changed into the repo dir and then back.
|
||||
mock_chdir.assert_has_calls(
|
||||
[call("/repos/dummy"), call("/cwd")]
|
||||
)
|
||||
mock_chdir.assert_has_calls([call("/repos/dummy"), call("/cwd")])
|
||||
|
||||
# And run_release should be invoked once with the expected parameters.
|
||||
mock_run_release.assert_called_once_with(
|
||||
|
||||
@@ -30,10 +30,12 @@ class TestCLIReleasePublishHook(unittest.TestCase):
|
||||
no_publish=False,
|
||||
)
|
||||
|
||||
with patch("pkgmgr.cli.commands.release.run_release") as m_release, patch(
|
||||
"pkgmgr.cli.commands.release.run_publish"
|
||||
) as m_publish, patch(
|
||||
"pkgmgr.cli.commands.release.sys.stdin.isatty", return_value=False
|
||||
with (
|
||||
patch("pkgmgr.cli.commands.release.run_release") as m_release,
|
||||
patch("pkgmgr.cli.commands.release.run_publish") as m_publish,
|
||||
patch(
|
||||
"pkgmgr.cli.commands.release.sys.stdin.isatty", return_value=False
|
||||
),
|
||||
):
|
||||
handle_release(args=args, ctx=self._ctx(), selected=[repo])
|
||||
|
||||
@@ -62,9 +64,10 @@ class TestCLIReleasePublishHook(unittest.TestCase):
|
||||
no_publish=True,
|
||||
)
|
||||
|
||||
with patch("pkgmgr.cli.commands.release.run_release") as m_release, patch(
|
||||
"pkgmgr.cli.commands.release.run_publish"
|
||||
) as m_publish:
|
||||
with (
|
||||
patch("pkgmgr.cli.commands.release.run_release") as m_release,
|
||||
patch("pkgmgr.cli.commands.release.run_publish") as m_publish,
|
||||
):
|
||||
handle_release(args=args, ctx=self._ctx(), selected=[repo])
|
||||
|
||||
m_release.assert_called_once()
|
||||
|
||||
@@ -79,9 +79,10 @@ class TestReposCommand(unittest.TestCase):
|
||||
|
||||
buf = io.StringIO()
|
||||
|
||||
with patch(
|
||||
"pkgmgr.cli.commands.repos.get_repo_dir"
|
||||
) as mock_get_repo_dir, redirect_stdout(buf):
|
||||
with (
|
||||
patch("pkgmgr.cli.commands.repos.get_repo_dir") as mock_get_repo_dir,
|
||||
redirect_stdout(buf),
|
||||
):
|
||||
handle_repos_command(args, ctx, selected=repos)
|
||||
|
||||
output = buf.getvalue().strip().splitlines()
|
||||
@@ -113,10 +114,13 @@ class TestReposCommand(unittest.TestCase):
|
||||
|
||||
buf = io.StringIO()
|
||||
|
||||
with patch(
|
||||
"pkgmgr.cli.commands.repos.get_repo_dir",
|
||||
return_value="/resolved/from/get_repo_dir",
|
||||
) as mock_get_repo_dir, redirect_stdout(buf):
|
||||
with (
|
||||
patch(
|
||||
"pkgmgr.cli.commands.repos.get_repo_dir",
|
||||
return_value="/resolved/from/get_repo_dir",
|
||||
) as mock_get_repo_dir,
|
||||
redirect_stdout(buf),
|
||||
):
|
||||
handle_repos_command(args, ctx, selected=repos)
|
||||
|
||||
output = buf.getvalue().strip().splitlines()
|
||||
@@ -168,12 +172,13 @@ class TestReposCommand(unittest.TestCase):
|
||||
shell_command=["echo", "hello"],
|
||||
)
|
||||
|
||||
with patch(
|
||||
"pkgmgr.cli.commands.repos.get_repo_dir",
|
||||
return_value="/resolved/for/shell",
|
||||
) as mock_get_repo_dir, patch(
|
||||
"pkgmgr.cli.commands.repos.run_command"
|
||||
) as mock_run_command:
|
||||
with (
|
||||
patch(
|
||||
"pkgmgr.cli.commands.repos.get_repo_dir",
|
||||
return_value="/resolved/for/shell",
|
||||
) as mock_get_repo_dir,
|
||||
patch("pkgmgr.cli.commands.repos.run_command") as mock_run_command,
|
||||
):
|
||||
buf = io.StringIO()
|
||||
with redirect_stdout(buf):
|
||||
handle_repos_command(args, ctx, selected=repos)
|
||||
@@ -185,7 +190,7 @@ class TestReposCommand(unittest.TestCase):
|
||||
mock_run_command.assert_called_once()
|
||||
called_args, called_kwargs = mock_run_command.call_args
|
||||
|
||||
self.assertEqual("echo hello", called_args[0]) # command string
|
||||
self.assertEqual("echo hello", called_args[0]) # command string
|
||||
self.assertEqual("/resolved/for/shell", called_kwargs["cwd"])
|
||||
self.assertFalse(called_kwargs["preview"])
|
||||
|
||||
|
||||
@@ -115,13 +115,16 @@ class TestCliVersion(unittest.TestCase):
|
||||
"""
|
||||
Write a minimal PEP 621-style pyproject.toml into the temp directory.
|
||||
"""
|
||||
content = textwrap.dedent(
|
||||
f"""
|
||||
content = (
|
||||
textwrap.dedent(
|
||||
f"""
|
||||
[project]
|
||||
name = "pkgmgr-test"
|
||||
version = "{version}"
|
||||
"""
|
||||
).strip() + "\n"
|
||||
).strip()
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
path = os.path.join(self._tmp_dir.name, "pyproject.toml")
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
|
||||
@@ -27,7 +27,9 @@ class TestCliBranch(unittest.TestCase):
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@patch("pkgmgr.cli.commands.branch.open_branch")
|
||||
def test_handle_branch_open_forwards_args_to_open_branch(self, mock_open_branch) -> None:
|
||||
def test_handle_branch_open_forwards_args_to_open_branch(
|
||||
self, mock_open_branch
|
||||
) -> None:
|
||||
"""
|
||||
handle_branch('open') should call open_branch with name, base and cwd='.'.
|
||||
"""
|
||||
@@ -49,7 +51,9 @@ class TestCliBranch(unittest.TestCase):
|
||||
self.assertEqual(call_kwargs.get("cwd"), ".")
|
||||
|
||||
@patch("pkgmgr.cli.commands.branch.open_branch")
|
||||
def test_handle_branch_open_uses_default_base_when_not_set(self, mock_open_branch) -> None:
|
||||
def test_handle_branch_open_uses_default_base_when_not_set(
|
||||
self, mock_open_branch
|
||||
) -> None:
|
||||
"""
|
||||
If --base is not passed, argparse gives base='main' (default),
|
||||
and handle_branch should propagate that to open_branch.
|
||||
@@ -75,7 +79,9 @@ class TestCliBranch(unittest.TestCase):
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@patch("pkgmgr.cli.commands.branch.close_branch")
|
||||
def test_handle_branch_close_forwards_args_to_close_branch(self, mock_close_branch) -> None:
|
||||
def test_handle_branch_close_forwards_args_to_close_branch(
|
||||
self, mock_close_branch
|
||||
) -> None:
|
||||
"""
|
||||
handle_branch('close') should call close_branch with name, base,
|
||||
cwd='.' and force=False by default.
|
||||
@@ -100,7 +106,9 @@ class TestCliBranch(unittest.TestCase):
|
||||
self.assertFalse(call_kwargs.get("force"))
|
||||
|
||||
@patch("pkgmgr.cli.commands.branch.close_branch")
|
||||
def test_handle_branch_close_uses_default_base_when_not_set(self, mock_close_branch) -> None:
|
||||
def test_handle_branch_close_uses_default_base_when_not_set(
|
||||
self, mock_close_branch
|
||||
) -> None:
|
||||
"""
|
||||
If --base is not passed for 'close', argparse gives base='main'
|
||||
(default), and handle_branch should propagate that to close_branch.
|
||||
@@ -153,7 +161,9 @@ class TestCliBranch(unittest.TestCase):
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@patch("pkgmgr.cli.commands.branch.drop_branch")
|
||||
def test_handle_branch_drop_forwards_args_to_drop_branch(self, mock_drop_branch) -> None:
|
||||
def test_handle_branch_drop_forwards_args_to_drop_branch(
|
||||
self, mock_drop_branch
|
||||
) -> None:
|
||||
"""
|
||||
handle_branch('drop') should call drop_branch with name, base,
|
||||
cwd='.' and force=False by default.
|
||||
@@ -178,7 +188,9 @@ class TestCliBranch(unittest.TestCase):
|
||||
self.assertFalse(call_kwargs.get("force"))
|
||||
|
||||
@patch("pkgmgr.cli.commands.branch.drop_branch")
|
||||
def test_handle_branch_drop_uses_default_base_when_not_set(self, mock_drop_branch) -> None:
|
||||
def test_handle_branch_drop_uses_default_base_when_not_set(
|
||||
self, mock_drop_branch
|
||||
) -> None:
|
||||
"""
|
||||
If --base is not passed for 'drop', argparse gives base='main'
|
||||
(default), and handle_branch should propagate that to drop_branch.
|
||||
|
||||
@@ -20,7 +20,9 @@ class TestResolveRepositoryPath(unittest.TestCase):
|
||||
ctx = SimpleNamespace(repositories_base_dir="/base", repositories_dir="/base2")
|
||||
repo = {"provider": "github.com", "account": "acme", "repository": "demo"}
|
||||
|
||||
with patch("pkgmgr.cli.tools.paths.get_repo_dir", return_value="/computed/repo") as m:
|
||||
with patch(
|
||||
"pkgmgr.cli.tools.paths.get_repo_dir", return_value="/computed/repo"
|
||||
) as m:
|
||||
out = resolve_repository_path(repo, ctx)
|
||||
|
||||
self.assertEqual(out, "/computed/repo")
|
||||
|
||||
@@ -27,7 +27,9 @@ class TestOpenVSCodeWorkspace(unittest.TestCase):
|
||||
from pkgmgr.cli.tools.vscode import open_vscode_workspace
|
||||
|
||||
ctx = SimpleNamespace(config_merged={}, all_repositories=[])
|
||||
selected: List[Repository] = [{"provider": "github.com", "account": "x", "repository": "y"}]
|
||||
selected: List[Repository] = [
|
||||
{"provider": "github.com", "account": "x", "repository": "y"}
|
||||
]
|
||||
|
||||
with patch("pkgmgr.cli.tools.vscode.shutil.which", return_value=None):
|
||||
with self.assertRaises(RuntimeError) as cm:
|
||||
@@ -42,11 +44,16 @@ class TestOpenVSCodeWorkspace(unittest.TestCase):
|
||||
config_merged={"directories": {"workspaces": "~/Workspaces"}},
|
||||
all_repositories=[],
|
||||
)
|
||||
selected: List[Repository] = [{"provider": "github.com", "account": "x", "repository": "y"}]
|
||||
selected: List[Repository] = [
|
||||
{"provider": "github.com", "account": "x", "repository": "y"}
|
||||
]
|
||||
|
||||
with patch("pkgmgr.cli.tools.vscode.shutil.which", return_value="/usr/bin/code"), patch(
|
||||
"pkgmgr.cli.tools.vscode.get_repo_identifier",
|
||||
return_value="github.com/x/y",
|
||||
with (
|
||||
patch("pkgmgr.cli.tools.vscode.shutil.which", return_value="/usr/bin/code"),
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.get_repo_identifier",
|
||||
return_value="github.com/x/y",
|
||||
),
|
||||
):
|
||||
with self.assertRaises(RuntimeError) as cm:
|
||||
open_vscode_workspace(ctx, selected)
|
||||
@@ -68,18 +75,27 @@ class TestOpenVSCodeWorkspace(unittest.TestCase):
|
||||
repositories_base_dir=os.path.join(tmp, "Repos"),
|
||||
)
|
||||
selected: List[Repository] = [
|
||||
{"provider": "github.com", "account": "kevin", "repository": "dotlinker"}
|
||||
{
|
||||
"provider": "github.com",
|
||||
"account": "kevin",
|
||||
"repository": "dotlinker",
|
||||
}
|
||||
]
|
||||
|
||||
with patch("pkgmgr.cli.tools.vscode.shutil.which", return_value="/usr/bin/code"), patch(
|
||||
"pkgmgr.cli.tools.vscode.get_repo_identifier",
|
||||
return_value="dotlinker",
|
||||
), patch(
|
||||
"pkgmgr.cli.tools.vscode.resolve_repository_path",
|
||||
return_value=repo_path,
|
||||
), patch(
|
||||
"pkgmgr.cli.tools.vscode.run_command"
|
||||
) as run_cmd:
|
||||
with (
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.shutil.which", return_value="/usr/bin/code"
|
||||
),
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.get_repo_identifier",
|
||||
return_value="dotlinker",
|
||||
),
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.resolve_repository_path",
|
||||
return_value=repo_path,
|
||||
),
|
||||
patch("pkgmgr.cli.tools.vscode.run_command") as run_cmd,
|
||||
):
|
||||
open_vscode_workspace(ctx, selected)
|
||||
|
||||
workspace_file = os.path.join(workspaces_dir, "dotlinker.code-workspace")
|
||||
@@ -110,18 +126,27 @@ class TestOpenVSCodeWorkspace(unittest.TestCase):
|
||||
all_repositories=[],
|
||||
)
|
||||
selected: List[Repository] = [
|
||||
{"provider": "github.com", "account": "kevin", "repository": "dotlinker"}
|
||||
{
|
||||
"provider": "github.com",
|
||||
"account": "kevin",
|
||||
"repository": "dotlinker",
|
||||
}
|
||||
]
|
||||
|
||||
with patch("pkgmgr.cli.tools.vscode.shutil.which", return_value="/usr/bin/code"), patch(
|
||||
"pkgmgr.cli.tools.vscode.get_repo_identifier",
|
||||
return_value="dotlinker",
|
||||
), patch(
|
||||
"pkgmgr.cli.tools.vscode.resolve_repository_path",
|
||||
return_value="/new/path",
|
||||
), patch(
|
||||
"pkgmgr.cli.tools.vscode.run_command"
|
||||
) as run_cmd:
|
||||
with (
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.shutil.which", return_value="/usr/bin/code"
|
||||
),
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.get_repo_identifier",
|
||||
return_value="dotlinker",
|
||||
),
|
||||
patch(
|
||||
"pkgmgr.cli.tools.vscode.resolve_repository_path",
|
||||
return_value="/new/path",
|
||||
),
|
||||
patch("pkgmgr.cli.tools.vscode.run_command") as run_cmd,
|
||||
):
|
||||
open_vscode_workspace(ctx, selected)
|
||||
|
||||
with open(workspace_file, "r", encoding="utf-8") as f:
|
||||
|
||||
Reference in new issue
Block a user