Release version 0.3.0
This commit is contained in:
64
tests/e2e/test_integration_list_commands.py
Normal file
64
tests/e2e/test_integration_list_commands.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import runpy
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from test_integration_version_commands import PROJECT_ROOT
|
||||
|
||||
|
||||
class TestIntegrationListCommands(unittest.TestCase):
|
||||
"""
|
||||
Integration tests for `pkgmgr list` with the new selection and
|
||||
description behaviour.
|
||||
"""
|
||||
|
||||
def _run_pkgmgr(self, args: list[str], cwd: str | None = None) -> None:
|
||||
cmd_repr = "pkgmgr " + " ".join(args)
|
||||
original_argv = list(sys.argv)
|
||||
original_cwd = os.getcwd()
|
||||
|
||||
try:
|
||||
if cwd is not None:
|
||||
os.chdir(cwd)
|
||||
|
||||
# Simulate: pkgmgr <args...>
|
||||
sys.argv = ["pkgmgr"] + args
|
||||
|
||||
try:
|
||||
runpy.run_module("main", run_name="__main__")
|
||||
except SystemExit as exc:
|
||||
code = exc.code if isinstance(exc.code, int) else str(exc.code)
|
||||
if code != 0:
|
||||
print()
|
||||
print(f"[TEST] Command : {cmd_repr}")
|
||||
print(f"[TEST] Working directory: {os.getcwd()}")
|
||||
print(f"[TEST] Exit code : {code}")
|
||||
raise AssertionError(
|
||||
f"{cmd_repr!r} failed with exit code {code}. "
|
||||
"Scroll up to inspect the output printed before failure."
|
||||
) from exc
|
||||
finally:
|
||||
os.chdir(original_cwd)
|
||||
sys.argv = original_argv
|
||||
|
||||
def test_list_all_repositories(self) -> None:
|
||||
"""
|
||||
`pkgmgr list --all` should successfully print the summary table.
|
||||
"""
|
||||
self._run_pkgmgr(["list", "--all"], cwd=PROJECT_ROOT)
|
||||
|
||||
def test_list_all_with_description(self) -> None:
|
||||
"""
|
||||
`pkgmgr list --all --description` should print the table plus the
|
||||
detailed section for each repository.
|
||||
"""
|
||||
self._run_pkgmgr(["list", "--all", "--description"], cwd=PROJECT_ROOT)
|
||||
|
||||
def test_list_with_string_filter(self) -> None:
|
||||
"""
|
||||
`pkgmgr list --string pkgmgr` exercises the new string-based
|
||||
selection logic on top of the defaults + user config.
|
||||
"""
|
||||
self._run_pkgmgr(["list", "--string", "pkgmgr"], cwd=PROJECT_ROOT)
|
||||
65
tests/e2e/test_integration_proxy_commands.py
Normal file
65
tests/e2e/test_integration_proxy_commands.py
Normal file
@@ -0,0 +1,65 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import runpy
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from test_integration_version_commands import PROJECT_ROOT
|
||||
|
||||
|
||||
class TestIntegrationProxyCommands(unittest.TestCase):
|
||||
"""
|
||||
Integration tests for proxy commands (e.g. git pull) using the new
|
||||
selection logic and `--preview` mode so no real changes are made.
|
||||
"""
|
||||
|
||||
def _run_pkgmgr(self, args: list[str], cwd: str | None = None) -> None:
|
||||
cmd_repr = "pkgmgr " + " ".join(args)
|
||||
original_argv = list(sys.argv)
|
||||
original_cwd = os.getcwd()
|
||||
|
||||
try:
|
||||
if cwd is not None:
|
||||
os.chdir(cwd)
|
||||
|
||||
# Simulate: pkgmgr <args...>
|
||||
sys.argv = ["pkgmgr"] + args
|
||||
|
||||
try:
|
||||
runpy.run_module("main", run_name="__main__")
|
||||
except SystemExit as exc:
|
||||
code = exc.code if isinstance(exc.code, int) else str(exc.code)
|
||||
if code != 0:
|
||||
print()
|
||||
print(f"[TEST] Command : {cmd_repr}")
|
||||
print(f"[TEST] Working directory: {os.getcwd()}")
|
||||
print(f"[TEST] Exit code : {code}")
|
||||
raise AssertionError(
|
||||
f"{cmd_repr!r} failed with exit code {code}. "
|
||||
"Scroll up to inspect the output printed before failure."
|
||||
) from exc
|
||||
finally:
|
||||
os.chdir(original_cwd)
|
||||
sys.argv = original_argv
|
||||
|
||||
def test_git_pull_preview_for_pkgmgr(self) -> None:
|
||||
"""
|
||||
`pkgmgr pull --preview pkgmgr` should go through the proxy layer,
|
||||
use get_selected_repos() and only print the underlying git pull
|
||||
command without executing it.
|
||||
"""
|
||||
self._run_pkgmgr(
|
||||
["pull", "--preview", "pkgmgr"],
|
||||
cwd=PROJECT_ROOT,
|
||||
)
|
||||
|
||||
def test_git_pull_preview_with_string_filter(self) -> None:
|
||||
"""
|
||||
`pkgmgr pull --preview --string pkgmgr` exercises the proxy +
|
||||
filter-only selection path.
|
||||
"""
|
||||
self._run_pkgmgr(
|
||||
["pull", "--preview", "--string", "pkgmgr"],
|
||||
cwd=PROJECT_ROOT,
|
||||
)
|
||||
@@ -73,20 +73,16 @@ class TestCliVersion(unittest.TestCase):
|
||||
# Patch get_selected_repos so that 'version' operates on our temp dir.
|
||||
# In the new modular CLI this function is used inside
|
||||
# pkgmgr.cli_core.dispatch, so we patch it there.
|
||||
def _fake_selected_repos(
|
||||
all_flag: bool,
|
||||
repos: List[dict],
|
||||
identifiers: List[str],
|
||||
):
|
||||
# We always return exactly one "repository" whose directory is the temp dir.
|
||||
def _fake_selected_repos(args, all_repositories):
|
||||
return [
|
||||
{
|
||||
"provider": "github.com",
|
||||
"account": "test",
|
||||
"repository": "pkgmgr-test",
|
||||
"directory": self._tmp_dir.name,
|
||||
}
|
||||
]
|
||||
{
|
||||
"provider": "github.com",
|
||||
"account": "test",
|
||||
"repository": "pkgmgr-test",
|
||||
"directory": self._tmp_dir.name,
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
self._patch_get_selected_repos = mock.patch(
|
||||
"pkgmgr.cli_core.dispatch.get_selected_repos",
|
||||
|
||||
Reference in New Issue
Block a user