diff --git a/pkgmgr/actions/repository/install/__init__.py b/pkgmgr/actions/install/__init__.py similarity index 92% rename from pkgmgr/actions/repository/install/__init__.py rename to pkgmgr/actions/install/__init__.py index c149860..ac32f1f 100644 --- a/pkgmgr/actions/repository/install/__init__.py +++ b/pkgmgr/actions/install/__init__.py @@ -21,20 +21,20 @@ from pkgmgr.core.repository.identifier import get_repo_identifier from pkgmgr.core.repository.dir import get_repo_dir from pkgmgr.core.repository.verify import verify_repository from pkgmgr.actions.repository.clone import clone_repos -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.os_packages import ( +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.os_packages import ( ArchPkgbuildInstaller, DebianControlInstaller, RpmSpecInstaller, ) -from pkgmgr.actions.repository.install.installers.nix_flake import ( +from pkgmgr.actions.install.installers.nix_flake import ( NixFlakeInstaller, ) -from pkgmgr.actions.repository.install.installers.python import PythonInstaller -from pkgmgr.actions.repository.install.installers.makefile import ( +from pkgmgr.actions.install.installers.python import PythonInstaller +from pkgmgr.actions.install.installers.makefile import ( MakefileInstaller, ) -from pkgmgr.actions.repository.install.pipeline import InstallationPipeline +from pkgmgr.actions.install.pipeline import InstallationPipeline Repository = Dict[str, Any] diff --git a/pkgmgr/actions/repository/install/capabilities.py b/pkgmgr/actions/install/capabilities.py similarity index 99% rename from pkgmgr/actions/repository/install/capabilities.py rename to pkgmgr/actions/install/capabilities.py index 25def88..0532cb0 100644 --- a/pkgmgr/actions/repository/install/capabilities.py +++ b/pkgmgr/actions/install/capabilities.py @@ -38,7 +38,7 @@ from abc import ABC, abstractmethod from typing import Iterable, TYPE_CHECKING if TYPE_CHECKING: - from pkgmgr.actions.repository.install.context import RepoContext + from pkgmgr.actions.install.context import RepoContext # --------------------------------------------------------------------------- diff --git a/pkgmgr/actions/repository/install/context.py b/pkgmgr/actions/install/context.py similarity index 100% rename from pkgmgr/actions/repository/install/context.py rename to pkgmgr/actions/install/context.py diff --git a/pkgmgr/actions/install/installers/__init__.py b/pkgmgr/actions/install/installers/__init__.py new file mode 100644 index 0000000..1fcb690 --- /dev/null +++ b/pkgmgr/actions/install/installers/__init__.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +Installer package for pkgmgr. + +This exposes all installer classes so users can import them directly from +pkgmgr.actions.install.installers. +""" + +from pkgmgr.actions.install.installers.base import BaseInstaller # noqa: F401 +from pkgmgr.actions.install.installers.nix_flake import NixFlakeInstaller # noqa: F401 +from pkgmgr.actions.install.installers.python import PythonInstaller # noqa: F401 +from pkgmgr.actions.install.installers.makefile import MakefileInstaller # noqa: F401 + +# OS-specific installers +from pkgmgr.actions.install.installers.os_packages.arch_pkgbuild import ArchPkgbuildInstaller # noqa: F401 +from pkgmgr.actions.install.installers.os_packages.debian_control import DebianControlInstaller # noqa: F401 +from pkgmgr.actions.install.installers.os_packages.rpm_spec import RpmSpecInstaller # noqa: F401 diff --git a/pkgmgr/actions/repository/install/installers/base.py b/pkgmgr/actions/install/installers/base.py similarity index 93% rename from pkgmgr/actions/repository/install/installers/base.py rename to pkgmgr/actions/install/installers/base.py index 4ffe7cb..9a4a8b7 100644 --- a/pkgmgr/actions/repository/install/installers/base.py +++ b/pkgmgr/actions/install/installers/base.py @@ -8,8 +8,8 @@ Base interface for all installer components in the pkgmgr installation pipeline. from abc import ABC, abstractmethod from typing import Set -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.capabilities import CAPABILITY_MATCHERS +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.capabilities import CAPABILITY_MATCHERS class BaseInstaller(ABC): diff --git a/pkgmgr/actions/repository/install/installers/makefile.py b/pkgmgr/actions/install/installers/makefile.py similarity index 95% rename from pkgmgr/actions/repository/install/installers/makefile.py rename to pkgmgr/actions/install/installers/makefile.py index d4da786..b2b5a2b 100644 --- a/pkgmgr/actions/repository/install/installers/makefile.py +++ b/pkgmgr/actions/install/installers/makefile.py @@ -3,8 +3,8 @@ from __future__ import annotations import os import re -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command diff --git a/pkgmgr/actions/repository/install/installers/nix_flake.py b/pkgmgr/actions/install/installers/nix_flake.py similarity index 96% rename from pkgmgr/actions/repository/install/installers/nix_flake.py rename to pkgmgr/actions/install/installers/nix_flake.py index 60df3aa..53977cb 100644 --- a/pkgmgr/actions/repository/install/installers/nix_flake.py +++ b/pkgmgr/actions/install/installers/nix_flake.py @@ -29,12 +29,12 @@ import os import shutil from typing import TYPE_CHECKING, List, Tuple -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command if TYPE_CHECKING: - from pkgmgr.actions.repository.install.context import RepoContext - from pkgmgr.actions.repository.install import InstallContext + from pkgmgr.actions.install.context import RepoContext + from pkgmgr.actions.install import InstallContext class NixFlakeInstaller(BaseInstaller): diff --git a/pkgmgr/actions/repository/install/installers/os_packages/__init__.py b/pkgmgr/actions/install/installers/os_packages/__init__.py similarity index 100% rename from pkgmgr/actions/repository/install/installers/os_packages/__init__.py rename to pkgmgr/actions/install/installers/os_packages/__init__.py diff --git a/pkgmgr/actions/repository/install/installers/os_packages/arch_pkgbuild.py b/pkgmgr/actions/install/installers/os_packages/arch_pkgbuild.py similarity index 92% rename from pkgmgr/actions/repository/install/installers/os_packages/arch_pkgbuild.py rename to pkgmgr/actions/install/installers/os_packages/arch_pkgbuild.py index ca299a7..b7d72f9 100644 --- a/pkgmgr/actions/repository/install/installers/os_packages/arch_pkgbuild.py +++ b/pkgmgr/actions/install/installers/os_packages/arch_pkgbuild.py @@ -3,8 +3,8 @@ import os import shutil -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command diff --git a/pkgmgr/actions/repository/install/installers/os_packages/debian_control.py b/pkgmgr/actions/install/installers/os_packages/debian_control.py similarity index 97% rename from pkgmgr/actions/repository/install/installers/os_packages/debian_control.py rename to pkgmgr/actions/install/installers/os_packages/debian_control.py index 5a9c521..5eff16b 100644 --- a/pkgmgr/actions/repository/install/installers/os_packages/debian_control.py +++ b/pkgmgr/actions/install/installers/os_packages/debian_control.py @@ -19,8 +19,8 @@ import os import shutil from typing import List -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command diff --git a/pkgmgr/actions/repository/install/installers/os_packages/rpm_spec.py b/pkgmgr/actions/install/installers/os_packages/rpm_spec.py similarity index 98% rename from pkgmgr/actions/repository/install/installers/os_packages/rpm_spec.py rename to pkgmgr/actions/install/installers/os_packages/rpm_spec.py index 9b09f29..e17b75a 100644 --- a/pkgmgr/actions/repository/install/installers/os_packages/rpm_spec.py +++ b/pkgmgr/actions/install/installers/os_packages/rpm_spec.py @@ -21,8 +21,8 @@ import shutil import tarfile from typing import List, Optional, Tuple -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command diff --git a/pkgmgr/actions/repository/install/installers/python.py b/pkgmgr/actions/install/installers/python.py similarity index 95% rename from pkgmgr/actions/repository/install/installers/python.py rename to pkgmgr/actions/install/installers/python.py index 44f9bc9..59846d7 100644 --- a/pkgmgr/actions/repository/install/installers/python.py +++ b/pkgmgr/actions/install/installers/python.py @@ -31,12 +31,12 @@ import sys import subprocess from typing import TYPE_CHECKING -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +from pkgmgr.actions.install.installers.base import BaseInstaller from pkgmgr.core.command.run import run_command if TYPE_CHECKING: - from pkgmgr.actions.repository.install.context import RepoContext - from pkgmgr.actions.repository.install import InstallContext + from pkgmgr.actions.install.context import RepoContext + from pkgmgr.actions.install import InstallContext class PythonInstaller(BaseInstaller): diff --git a/pkgmgr/actions/repository/install/layers.py b/pkgmgr/actions/install/layers.py similarity index 100% rename from pkgmgr/actions/repository/install/layers.py rename to pkgmgr/actions/install/layers.py diff --git a/pkgmgr/actions/repository/install/pipeline.py b/pkgmgr/actions/install/pipeline.py similarity index 97% rename from pkgmgr/actions/repository/install/pipeline.py rename to pkgmgr/actions/install/pipeline.py index 6ed6f68..8202bc6 100644 --- a/pkgmgr/actions/repository/install/pipeline.py +++ b/pkgmgr/actions/install/pipeline.py @@ -23,9 +23,9 @@ from __future__ import annotations from dataclasses import dataclass from typing import Optional, Sequence, Set -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.base import BaseInstaller -from pkgmgr.actions.repository.install.layers import ( +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller +from pkgmgr.actions.install.layers import ( CliLayer, classify_command_layer, layer_priority, diff --git a/pkgmgr/actions/repository/install/installers/__init__.py b/pkgmgr/actions/repository/install/installers/__init__.py deleted file mode 100644 index e546b8c..0000000 --- a/pkgmgr/actions/repository/install/installers/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -""" -Installer package for pkgmgr. - -This exposes all installer classes so users can import them directly from -pkgmgr.actions.repository.install.installers. -""" - -from pkgmgr.actions.repository.install.installers.base import BaseInstaller # noqa: F401 -from pkgmgr.actions.repository.install.installers.nix_flake import NixFlakeInstaller # noqa: F401 -from pkgmgr.actions.repository.install.installers.python import PythonInstaller # noqa: F401 -from pkgmgr.actions.repository.install.installers.makefile import MakefileInstaller # noqa: F401 - -# OS-specific installers -from pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild import ArchPkgbuildInstaller # noqa: F401 -from pkgmgr.actions.repository.install.installers.os_packages.debian_control import DebianControlInstaller # noqa: F401 -from pkgmgr.actions.repository.install.installers.os_packages.rpm_spec import RpmSpecInstaller # noqa: F401 diff --git a/pkgmgr/actions/repository/update.py b/pkgmgr/actions/repository/update.py index df6416f..08b784c 100644 --- a/pkgmgr/actions/repository/update.py +++ b/pkgmgr/actions/repository/update.py @@ -2,7 +2,7 @@ import sys import shutil from pkgmgr.actions.repository.pull import pull_with_verification -from pkgmgr.actions.repository.install import install_repos +from pkgmgr.actions.install import install_repos def update_repos( diff --git a/pkgmgr/cli/commands/repos.py b/pkgmgr/cli/commands/repos.py index 7e8c2f4..febf9de 100644 --- a/pkgmgr/cli/commands/repos.py +++ b/pkgmgr/cli/commands/repos.py @@ -7,7 +7,7 @@ import sys from typing import Any, Dict, List from pkgmgr.cli.context import CLIContext -from pkgmgr.actions.repository.install import install_repos +from pkgmgr.actions.install import install_repos from pkgmgr.actions.repository.deinstall import deinstall_repos from pkgmgr.actions.repository.delete import delete_repos from pkgmgr.actions.repository.update import update_repos diff --git a/tests/integration/test_install_repos.py b/tests/integration/test_install_repos.py index 5829fbd..243fc52 100644 --- a/tests/integration/test_install_repos.py +++ b/tests/integration/test_install_repos.py @@ -6,9 +6,9 @@ import tempfile import unittest from unittest.mock import patch -import pkgmgr.actions.repository.install as install_module -from pkgmgr.actions.repository.install import install_repos -from pkgmgr.actions.repository.install.installers.base import BaseInstaller +import pkgmgr.actions.install as install_module +from pkgmgr.actions.install import install_repos +from pkgmgr.actions.install.installers.base import BaseInstaller class DummyInstaller(BaseInstaller): @@ -27,10 +27,10 @@ class DummyInstaller(BaseInstaller): class TestInstallReposIntegration(unittest.TestCase): - @patch("pkgmgr.actions.repository.install.verify_repository") - @patch("pkgmgr.actions.repository.install.clone_repos") - @patch("pkgmgr.actions.repository.install.get_repo_dir") - @patch("pkgmgr.actions.repository.install.get_repo_identifier") + @patch("pkgmgr.actions.install.verify_repository") + @patch("pkgmgr.actions.install.clone_repos") + @patch("pkgmgr.actions.install.get_repo_dir") + @patch("pkgmgr.actions.install.get_repo_identifier") def test_system_binary_vs_nix_binary( self, mock_get_repo_identifier, @@ -104,9 +104,9 @@ class TestInstallReposIntegration(unittest.TestCase): # Patch resolve_command_for_repo at the *pipeline* module level, # because InstallationPipeline imports it there. with patch( - "pkgmgr.actions.repository.install.pipeline.resolve_command_for_repo" + "pkgmgr.actions.install.pipeline.resolve_command_for_repo" ) as mock_resolve, patch( - "pkgmgr.actions.repository.install.os.path.exists" + "pkgmgr.actions.install.os.path.exists" ) as mock_exists_install: def fake_resolve(repo, repo_identifier: str, repo_dir: str): diff --git a/tests/integration/test_recursive_capabilities.py b/tests/integration/test_recursive_capabilities.py index 7d60427..796982b 100644 --- a/tests/integration/test_recursive_capabilities.py +++ b/tests/integration/test_recursive_capabilities.py @@ -20,14 +20,14 @@ import unittest from typing import List, Sequence, Tuple from unittest.mock import patch -import pkgmgr.actions.repository.install as install_mod -from pkgmgr.actions.repository.install import install_repos -from pkgmgr.actions.repository.install.installers.makefile import MakefileInstaller -from pkgmgr.actions.repository.install.installers.nix_flake import NixFlakeInstaller -from pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild import ( +import pkgmgr.actions.install as install_mod +from pkgmgr.actions.install import install_repos +from pkgmgr.actions.install.installers.makefile import MakefileInstaller +from pkgmgr.actions.install.installers.nix_flake import NixFlakeInstaller +from pkgmgr.actions.install.installers.os_packages.arch_pkgbuild import ( ArchPkgbuildInstaller, ) -from pkgmgr.actions.repository.install.installers.python import PythonInstaller +from pkgmgr.actions.install.installers.python import PythonInstaller InstallerSpec = Tuple[str, object] diff --git a/tests/unit/pkgmgr/actions/install/installers/os_packages/test_arch_pkgbuild.py b/tests/unit/pkgmgr/actions/install/installers/os_packages/test_arch_pkgbuild.py index 1fe2db8..60ebdbf 100644 --- a/tests/unit/pkgmgr/actions/install/installers/os_packages/test_arch_pkgbuild.py +++ b/tests/unit/pkgmgr/actions/install/installers/os_packages/test_arch_pkgbuild.py @@ -4,8 +4,8 @@ import os import unittest from unittest.mock import patch -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild import ArchPkgbuildInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.os_packages.arch_pkgbuild import ArchPkgbuildInstaller class TestArchPkgbuildInstaller(unittest.TestCase): @@ -26,7 +26,7 @@ class TestArchPkgbuildInstaller(unittest.TestCase): ) self.installer = ArchPkgbuildInstaller() - @patch("pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=1000) + @patch("pkgmgr.actions.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=1000) @patch("os.path.exists", return_value=True) @patch("shutil.which") def test_supports_true_when_tools_and_pkgbuild_exist( @@ -46,7 +46,7 @@ class TestArchPkgbuildInstaller(unittest.TestCase): self.assertIn("makepkg", calls) mock_exists.assert_called_with(os.path.join(self.ctx.repo_dir, "PKGBUILD")) - @patch("pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=0) + @patch("pkgmgr.actions.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=0) @patch("os.path.exists", return_value=True) @patch("shutil.which") def test_supports_false_when_running_as_root( @@ -55,7 +55,7 @@ class TestArchPkgbuildInstaller(unittest.TestCase): mock_which.return_value = "/usr/bin/pacman" self.assertFalse(self.installer.supports(self.ctx)) - @patch("pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=1000) + @patch("pkgmgr.actions.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=1000) @patch("os.path.exists", return_value=False) @patch("shutil.which") def test_supports_false_when_pkgbuild_missing( @@ -64,8 +64,8 @@ class TestArchPkgbuildInstaller(unittest.TestCase): mock_which.return_value = "/usr/bin/pacman" self.assertFalse(self.installer.supports(self.ctx)) - @patch("pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild.run_command") - @patch("pkgmgr.actions.repository.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=1000) + @patch("pkgmgr.actions.install.installers.os_packages.arch_pkgbuild.run_command") + @patch("pkgmgr.actions.install.installers.os_packages.arch_pkgbuild.os.geteuid", return_value=1000) @patch("os.path.exists", return_value=True) @patch("shutil.which") def test_run_builds_and_installs_with_makepkg( diff --git a/tests/unit/pkgmgr/actions/install/installers/os_packages/test_debian_control.py b/tests/unit/pkgmgr/actions/install/installers/os_packages/test_debian_control.py index f1370d4..3cca211 100644 --- a/tests/unit/pkgmgr/actions/install/installers/os_packages/test_debian_control.py +++ b/tests/unit/pkgmgr/actions/install/installers/os_packages/test_debian_control.py @@ -1,8 +1,8 @@ import unittest from unittest.mock import patch -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.os_packages.debian_control import ( +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.os_packages.debian_control import ( DebianControlInstaller, ) @@ -44,7 +44,7 @@ class TestDebianControlInstaller(unittest.TestCase): self.assertFalse(self.installer.supports(self.ctx)) @patch( - "pkgmgr.actions.repository.install.installers.os_packages.debian_control.run_command" + "pkgmgr.actions.install.installers.os_packages.debian_control.run_command" ) @patch("glob.glob", return_value=["/tmp/package-manager_0.1.1_all.deb"]) @patch("os.path.exists", return_value=True) diff --git a/tests/unit/pkgmgr/actions/install/installers/os_packages/test_rpm_spec.py b/tests/unit/pkgmgr/actions/install/installers/os_packages/test_rpm_spec.py index 8214da6..c0410c0 100644 --- a/tests/unit/pkgmgr/actions/install/installers/os_packages/test_rpm_spec.py +++ b/tests/unit/pkgmgr/actions/install/installers/os_packages/test_rpm_spec.py @@ -1,8 +1,8 @@ import unittest from unittest.mock import patch -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.os_packages.rpm_spec import ( +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.os_packages.rpm_spec import ( RpmSpecInstaller, ) @@ -57,7 +57,7 @@ class TestRpmSpecInstaller(unittest.TestCase): self.assertFalse(self.installer.supports(self.ctx)) @patch.object(RpmSpecInstaller, "_prepare_source_tarball") - @patch("pkgmgr.actions.repository.install.installers.os_packages.rpm_spec.run_command") + @patch("pkgmgr.actions.install.installers.os_packages.rpm_spec.run_command") @patch("glob.glob") @patch("shutil.which") def test_run_builds_and_installs_rpms( diff --git a/tests/unit/pkgmgr/actions/install/installers/test_base.py b/tests/unit/pkgmgr/actions/install/installers/test_base.py index c386bf1..6835de2 100644 --- a/tests/unit/pkgmgr/actions/install/installers/test_base.py +++ b/tests/unit/pkgmgr/actions/install/installers/test_base.py @@ -1,8 +1,8 @@ # tests/unit/pkgmgr/installers/test_base.py import unittest -from pkgmgr.actions.repository.install.installers.base import BaseInstaller -from pkgmgr.actions.repository.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller +from pkgmgr.actions.install.context import RepoContext class DummyInstaller(BaseInstaller): diff --git a/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py b/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py index e2c2e50..3290301 100644 --- a/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py +++ b/tests/unit/pkgmgr/actions/install/installers/test_makefile_installer.py @@ -4,8 +4,8 @@ import os import unittest from unittest.mock import patch, mock_open -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.makefile import MakefileInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.makefile import MakefileInstaller class TestMakefileInstaller(unittest.TestCase): @@ -35,7 +35,7 @@ class TestMakefileInstaller(unittest.TestCase): def test_supports_false_when_makefile_missing(self, mock_exists): self.assertFalse(self.installer.supports(self.ctx)) - @patch("pkgmgr.actions.repository.install.installers.makefile.run_command") + @patch("pkgmgr.actions.install.installers.makefile.run_command") @patch( "builtins.open", new_callable=mock_open, @@ -62,7 +62,7 @@ class TestMakefileInstaller(unittest.TestCase): self.ctx.repo_dir, ) - @patch("pkgmgr.actions.repository.install.installers.makefile.run_command") + @patch("pkgmgr.actions.install.installers.makefile.run_command") @patch( "builtins.open", new_callable=mock_open, diff --git a/tests/unit/pkgmgr/actions/install/installers/test_nix_flake.py b/tests/unit/pkgmgr/actions/install/installers/test_nix_flake.py index b49f346..e94e1c2 100644 --- a/tests/unit/pkgmgr/actions/install/installers/test_nix_flake.py +++ b/tests/unit/pkgmgr/actions/install/installers/test_nix_flake.py @@ -6,8 +6,8 @@ import unittest from unittest import mock from unittest.mock import MagicMock, patch -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.nix_flake import NixFlakeInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.nix_flake import NixFlakeInstaller class TestNixFlakeInstaller(unittest.TestCase): @@ -29,8 +29,8 @@ class TestNixFlakeInstaller(unittest.TestCase): ) self.installer = NixFlakeInstaller() - @patch("pkgmgr.actions.repository.install.installers.nix_flake.os.path.exists") - @patch("pkgmgr.actions.repository.install.installers.nix_flake.shutil.which") + @patch("pkgmgr.actions.install.installers.nix_flake.os.path.exists") + @patch("pkgmgr.actions.install.installers.nix_flake.shutil.which") def test_supports_true_when_nix_and_flake_exist( self, mock_which: MagicMock, @@ -47,8 +47,8 @@ class TestNixFlakeInstaller(unittest.TestCase): os.path.join(self.ctx.repo_dir, self.installer.FLAKE_FILE) ) - @patch("pkgmgr.actions.repository.install.installers.nix_flake.os.path.exists") - @patch("pkgmgr.actions.repository.install.installers.nix_flake.shutil.which") + @patch("pkgmgr.actions.install.installers.nix_flake.os.path.exists") + @patch("pkgmgr.actions.install.installers.nix_flake.shutil.which") def test_supports_false_when_nix_missing( self, mock_which: MagicMock, @@ -60,8 +60,8 @@ class TestNixFlakeInstaller(unittest.TestCase): with patch.dict(os.environ, {"PKGMGR_DISABLE_NIX_FLAKE_INSTALLER": ""}, clear=False): self.assertFalse(self.installer.supports(self.ctx)) - @patch("pkgmgr.actions.repository.install.installers.nix_flake.os.path.exists") - @patch("pkgmgr.actions.repository.install.installers.nix_flake.shutil.which") + @patch("pkgmgr.actions.install.installers.nix_flake.os.path.exists") + @patch("pkgmgr.actions.install.installers.nix_flake.shutil.which") def test_supports_false_when_disabled_via_env( self, mock_which: MagicMock, @@ -77,8 +77,8 @@ class TestNixFlakeInstaller(unittest.TestCase): ): self.assertFalse(self.installer.supports(self.ctx)) - @patch("pkgmgr.actions.repository.install.installers.nix_flake.NixFlakeInstaller.supports") - @patch("pkgmgr.actions.repository.install.installers.nix_flake.run_command") + @patch("pkgmgr.actions.install.installers.nix_flake.NixFlakeInstaller.supports") + @patch("pkgmgr.actions.install.installers.nix_flake.run_command") def test_run_removes_old_profile_and_installs_outputs( self, mock_run_command: MagicMock, @@ -112,8 +112,8 @@ class TestNixFlakeInstaller(unittest.TestCase): self.assertEqual(commands[0], remove_cmd) - @patch("pkgmgr.actions.repository.install.installers.nix_flake.shutil.which") - @patch("pkgmgr.actions.repository.install.installers.nix_flake.run_command") + @patch("pkgmgr.actions.install.installers.nix_flake.shutil.which") + @patch("pkgmgr.actions.install.installers.nix_flake.run_command") def test_ensure_old_profile_removed_ignores_systemexit( self, mock_run_command: MagicMock, diff --git a/tests/unit/pkgmgr/actions/install/installers/test_python_installer.py b/tests/unit/pkgmgr/actions/install/installers/test_python_installer.py index 3169667..e6fb655 100644 --- a/tests/unit/pkgmgr/actions/install/installers/test_python_installer.py +++ b/tests/unit/pkgmgr/actions/install/installers/test_python_installer.py @@ -2,8 +2,8 @@ import os import unittest from unittest.mock import patch -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.python import PythonInstaller +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.python import PythonInstaller class TestPythonInstaller(unittest.TestCase): @@ -41,7 +41,7 @@ class TestPythonInstaller(unittest.TestCase): with patch.dict(os.environ, {"IN_NIX_SHELL": ""}, clear=False): self.assertFalse(self.installer.supports(self.ctx)) - @patch("pkgmgr.actions.repository.install.installers.python.run_command") + @patch("pkgmgr.actions.install.installers.python.run_command") @patch("os.path.exists", side_effect=lambda path: path.endswith("pyproject.toml")) def test_run_installs_project_from_pyproject(self, mock_exists, mock_run_command): """ diff --git a/tests/unit/pkgmgr/actions/install/test_capabilities.py b/tests/unit/pkgmgr/actions/install/test_capabilities.py index 7f6bc74..c37b442 100644 --- a/tests/unit/pkgmgr/actions/install/test_capabilities.py +++ b/tests/unit/pkgmgr/actions/install/test_capabilities.py @@ -4,7 +4,7 @@ import os import unittest from unittest.mock import patch, mock_open -from pkgmgr.actions.repository.install.capabilities import ( +from pkgmgr.actions.install.capabilities import ( PythonRuntimeCapability, MakeInstallCapability, NixFlakeCapability, @@ -31,7 +31,7 @@ class TestCapabilitiesDetectors(unittest.TestCase): def setUp(self): self.ctx = DummyCtx("/tmp/repo") - @patch("pkgmgr.actions.repository.install.capabilities.os.path.exists") + @patch("pkgmgr.actions.install.capabilities.os.path.exists") def test_python_runtime_python_layer_pyproject(self, mock_exists): """PythonRuntimeCapability: python layer is provided if pyproject.toml exists.""" cap = PythonRuntimeCapability() @@ -47,8 +47,8 @@ class TestCapabilitiesDetectors(unittest.TestCase): self.assertFalse(cap.is_provided(self.ctx, "nix")) self.assertFalse(cap.is_provided(self.ctx, "os-packages")) - @patch("pkgmgr.actions.repository.install.capabilities._read_text_if_exists") - @patch("pkgmgr.actions.repository.install.capabilities.os.path.exists") + @patch("pkgmgr.actions.install.capabilities._read_text_if_exists") + @patch("pkgmgr.actions.install.capabilities.os.path.exists") def test_python_runtime_nix_layer_flake(self, mock_exists, mock_read): """ PythonRuntimeCapability: nix layer is provided if flake.nix contains @@ -65,7 +65,7 @@ class TestCapabilitiesDetectors(unittest.TestCase): self.assertTrue(cap.applies_to_layer("nix")) self.assertTrue(cap.is_provided(self.ctx, "nix")) - @patch("pkgmgr.actions.repository.install.capabilities.os.path.exists", return_value=True) + @patch("pkgmgr.actions.install.capabilities.os.path.exists", return_value=True) @patch( "builtins.open", new_callable=mock_open, @@ -78,7 +78,7 @@ class TestCapabilitiesDetectors(unittest.TestCase): self.assertTrue(cap.applies_to_layer("makefile")) self.assertTrue(cap.is_provided(self.ctx, "makefile")) - @patch("pkgmgr.actions.repository.install.capabilities.os.path.exists") + @patch("pkgmgr.actions.install.capabilities.os.path.exists") def test_nix_flake_capability_on_nix_layer(self, mock_exists): """NixFlakeCapability: nix layer is provided if flake.nix exists.""" cap = NixFlakeCapability() @@ -153,7 +153,7 @@ class TestDetectCapabilities(unittest.TestCase): }, ) - with patch("pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", [dummy1, dummy2]): + with patch("pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [dummy1, dummy2]): caps = detect_capabilities(self.ctx, layers) self.assertEqual( @@ -221,7 +221,7 @@ class TestResolveEffectiveCapabilities(unittest.TestCase): ) with patch( - "pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", + "pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [cap_make_install, cap_python_runtime, cap_nix_flake], ): effective = resolve_effective_capabilities(self.ctx, layers) @@ -258,7 +258,7 @@ class TestResolveEffectiveCapabilities(unittest.TestCase): ) with patch( - "pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", + "pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [cap_python_runtime], ): effective = resolve_effective_capabilities(self.ctx, layers) @@ -283,7 +283,7 @@ class TestResolveEffectiveCapabilities(unittest.TestCase): }, ) - with patch("pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", [cap_only_make]): + with patch("pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [cap_only_make]): effective = resolve_effective_capabilities(self.ctx, layers) self.assertEqual(effective["makefile"], {"make-install"}) @@ -306,7 +306,7 @@ class TestResolveEffectiveCapabilities(unittest.TestCase): }, ) - with patch("pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", [cap_only_nix]): + with patch("pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [cap_only_nix]): effective = resolve_effective_capabilities(self.ctx, layers) self.assertEqual(effective["makefile"], set()) @@ -337,7 +337,7 @@ class TestResolveEffectiveCapabilities(unittest.TestCase): ) with patch( - "pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", + "pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [cap_python_runtime], ): effective = resolve_effective_capabilities(self.ctx, layers) @@ -359,7 +359,7 @@ class TestResolveEffectiveCapabilities(unittest.TestCase): ) with patch( - "pkgmgr.actions.repository.install.capabilities.CAPABILITY_MATCHERS", + "pkgmgr.actions.install.capabilities.CAPABILITY_MATCHERS", [cap_dummy], ): effective = resolve_effective_capabilities(self.ctx) diff --git a/tests/unit/pkgmgr/actions/install/test_context.py b/tests/unit/pkgmgr/actions/install/test_context.py index 9713f7e..c28d129 100644 --- a/tests/unit/pkgmgr/actions/install/test_context.py +++ b/tests/unit/pkgmgr/actions/install/test_context.py @@ -1,5 +1,5 @@ import unittest -from pkgmgr.actions.repository.install.context import RepoContext +from pkgmgr.actions.install.context import RepoContext class TestRepoContext(unittest.TestCase): diff --git a/tests/unit/pkgmgr/actions/install/test_install_repos.py b/tests/unit/pkgmgr/actions/install/test_install_repos.py index 6c08cf3..1c4f043 100644 --- a/tests/unit/pkgmgr/actions/install/test_install_repos.py +++ b/tests/unit/pkgmgr/actions/install/test_install_repos.py @@ -6,7 +6,7 @@ import unittest from typing import Any, Dict, List from unittest.mock import MagicMock, patch -from pkgmgr.actions.repository.install import install_repos +from pkgmgr.actions.install import install_repos Repository = Dict[str, Any] @@ -31,12 +31,12 @@ class TestInstallReposOrchestration(unittest.TestCase): } self.all_repos: List[Repository] = [self.repo1, self.repo2] - @patch("pkgmgr.actions.repository.install.InstallationPipeline") - @patch("pkgmgr.actions.repository.install.clone_repos") - @patch("pkgmgr.actions.repository.install.get_repo_dir") - @patch("pkgmgr.actions.repository.install.os.path.exists", return_value=True) + @patch("pkgmgr.actions.install.InstallationPipeline") + @patch("pkgmgr.actions.install.clone_repos") + @patch("pkgmgr.actions.install.get_repo_dir") + @patch("pkgmgr.actions.install.os.path.exists", return_value=True) @patch( - "pkgmgr.actions.repository.install.verify_repository", + "pkgmgr.actions.install.verify_repository", return_value=(True, [], "hash", "key"), ) def test_install_repos_runs_pipeline_for_each_repo( @@ -79,12 +79,12 @@ class TestInstallReposOrchestration(unittest.TestCase): pipeline_instance = mock_pipeline_cls.return_value self.assertEqual(pipeline_instance.run.call_count, len(selected)) - @patch("pkgmgr.actions.repository.install.InstallationPipeline") - @patch("pkgmgr.actions.repository.install.clone_repos") - @patch("pkgmgr.actions.repository.install.get_repo_dir") - @patch("pkgmgr.actions.repository.install.os.path.exists", return_value=True) + @patch("pkgmgr.actions.install.InstallationPipeline") + @patch("pkgmgr.actions.install.clone_repos") + @patch("pkgmgr.actions.install.get_repo_dir") + @patch("pkgmgr.actions.install.os.path.exists", return_value=True) @patch( - "pkgmgr.actions.repository.install.verify_repository", + "pkgmgr.actions.install.verify_repository", return_value=(False, ["invalid signature"], None, None), ) @patch("builtins.input", return_value="n") diff --git a/tests/unit/pkgmgr/actions/install/test_layers.py b/tests/unit/pkgmgr/actions/install/test_layers.py index 1bbafae..28d385f 100644 --- a/tests/unit/pkgmgr/actions/install/test_layers.py +++ b/tests/unit/pkgmgr/actions/install/test_layers.py @@ -4,7 +4,7 @@ import os import unittest -from pkgmgr.actions.repository.install.layers import ( +from pkgmgr.actions.install.layers import ( CliLayer, CLI_LAYERS, classify_command_layer, diff --git a/tests/unit/pkgmgr/actions/install/test_pipeline.py b/tests/unit/pkgmgr/actions/install/test_pipeline.py index 84195eb..233cd15 100644 --- a/tests/unit/pkgmgr/actions/install/test_pipeline.py +++ b/tests/unit/pkgmgr/actions/install/test_pipeline.py @@ -4,10 +4,10 @@ import unittest from unittest.mock import MagicMock, patch -from pkgmgr.actions.repository.install.context import RepoContext -from pkgmgr.actions.repository.install.installers.base import BaseInstaller -from pkgmgr.actions.repository.install.layers import CliLayer -from pkgmgr.actions.repository.install.pipeline import InstallationPipeline +from pkgmgr.actions.install.context import RepoContext +from pkgmgr.actions.install.installers.base import BaseInstaller +from pkgmgr.actions.install.layers import CliLayer +from pkgmgr.actions.install.pipeline import InstallationPipeline class DummyInstaller(BaseInstaller): @@ -61,8 +61,8 @@ def _minimal_context() -> RepoContext: class TestInstallationPipeline(unittest.TestCase): - @patch("pkgmgr.actions.repository.install.pipeline.create_ink") - @patch("pkgmgr.actions.repository.install.pipeline.resolve_command_for_repo") + @patch("pkgmgr.actions.install.pipeline.create_ink") + @patch("pkgmgr.actions.install.pipeline.resolve_command_for_repo") def test_create_ink_called_when_command_resolved( self, mock_resolve_command_for_repo: MagicMock, @@ -86,8 +86,8 @@ class TestInstallationPipeline(unittest.TestCase): "/usr/local/bin/test-repo", ) - @patch("pkgmgr.actions.repository.install.pipeline.create_ink") - @patch("pkgmgr.actions.repository.install.pipeline.resolve_command_for_repo") + @patch("pkgmgr.actions.install.pipeline.create_ink") + @patch("pkgmgr.actions.install.pipeline.resolve_command_for_repo") def test_lower_priority_installers_are_skipped_if_cli_exists( self, mock_resolve_command_for_repo: MagicMock, @@ -116,8 +116,8 @@ class TestInstallationPipeline(unittest.TestCase): ) self.assertEqual(ctx.repo.get("command"), "/usr/bin/test-repo") - @patch("pkgmgr.actions.repository.install.pipeline.create_ink") - @patch("pkgmgr.actions.repository.install.pipeline.resolve_command_for_repo") + @patch("pkgmgr.actions.install.pipeline.create_ink") + @patch("pkgmgr.actions.install.pipeline.resolve_command_for_repo") def test_capabilities_prevent_duplicate_installers( self, mock_resolve_command_for_repo: MagicMock,