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 / linter-shell (push) Has been cancelled
Mark stable commit / linter-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
https://chatgpt.com/share/693f5bdb-1780-800f-a772-0ecf399627fc
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib
|
|
import io
|
|
import unittest
|
|
from contextlib import redirect_stdout
|
|
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
|
|
class TestIntegrationReposCreatePreview(unittest.TestCase):
|
|
def test_repos_create_preview_wires_create_repo(self) -> None:
|
|
# Import lazily to avoid hard-failing if the CLI module/function name differs.
|
|
try:
|
|
repos_mod = importlib.import_module("pkgmgr.cli.commands.repos")
|
|
except Exception as exc:
|
|
self.skipTest(f"CLI module not available: {exc}")
|
|
|
|
handle = getattr(repos_mod, "handle_repos_command", None)
|
|
if handle is None:
|
|
self.skipTest("handle_repos_command not found in pkgmgr.cli.commands.repos")
|
|
|
|
ctx = SimpleNamespace(
|
|
repositories_base_dir="/tmp/Repositories",
|
|
binaries_dir="/tmp/bin",
|
|
all_repositories=[],
|
|
config_merged={"directories": {"repositories": "/tmp/Repositories"}, "repositories": []},
|
|
user_config_path="/tmp/user.yml",
|
|
)
|
|
|
|
args = SimpleNamespace(
|
|
command="create",
|
|
identifiers=["github.com/acme/repo"],
|
|
remote=False,
|
|
preview=True,
|
|
)
|
|
|
|
out = io.StringIO()
|
|
with (
|
|
redirect_stdout(out),
|
|
patch("pkgmgr.cli.commands.repos.create_repo") as create_repo,
|
|
):
|
|
handle(args, ctx, selected=[])
|
|
|
|
create_repo.assert_called_once()
|
|
called = create_repo.call_args.kwargs
|
|
self.assertEqual(called["remote"], False)
|
|
self.assertEqual(called["preview"], True)
|
|
self.assertEqual(create_repo.call_args.args[0], "github.com/acme/repo")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|