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 a6a07a8..199f42a 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 @@ -72,6 +72,8 @@ class TestDebianControlInstaller(unittest.TestCase): return "/usr/bin/dpkg-buildpackage" if name == "apt-get": return "/usr/bin/apt-get" + if name == "sudo": + return "/usr/bin/sudo" return None mock_which.side_effect = which_side_effect diff --git a/tests/unit/pkgmgr/core/config/test_cli_update.py b/tests/unit/pkgmgr/core/config/test_cli_update.py index c535ede..ed1a5bc 100644 --- a/tests/unit/pkgmgr/core/config/test_cli_update.py +++ b/tests/unit/pkgmgr/core/config/test_cli_update.py @@ -29,22 +29,19 @@ class FindDefaultsSourceDirTests(unittest.TestCase): self.assertEqual(Path(found).resolve(), (pkg_root / "config").resolve()) - def test_falls_back_to_project_root_config(self): + def test_a_config_dir_beside_the_package_is_not_taken(self): with tempfile.TemporaryDirectory() as td: root = Path(td) pkg_root = root / "site-packages" / "pkgmgr" pkg_root.mkdir(parents=True) - # only project_root config exists (pkg_root.parent / "config").mkdir(parents=True) fake_pkgmgr = types.SimpleNamespace(__file__=str(pkg_root / "__init__.py")) with patch.dict(sys.modules, {"pkgmgr": fake_pkgmgr}): found = config_cmd._find_defaults_source_dir() - self.assertEqual( - Path(found).resolve(), (pkg_root.parent / "config").resolve() - ) + self.assertIsNone(found) def test_returns_none_when_no_config_dirs_exist(self): with tempfile.TemporaryDirectory() as td: @@ -88,9 +85,8 @@ class UpdateDefaultConfigsTests(unittest.TestCase): self.assertTrue((dest_cfg_dir / "a.yaml").is_file()) self.assertTrue((dest_cfg_dir / "b.yml").is_file()) self.assertFalse( - (dest_cfg_dir / "config.yaml") - .read_text(encoding="utf-8") - .startswith("should_not_copy") + (dest_cfg_dir / "config.yaml").exists(), + "the source config.yaml must not be copied over the user's own", ) # Ensure config.yaml was not overwritten (it may exist, but should remain original if we create it) diff --git a/tests/unit/pkgmgr/core/config/test_load.py b/tests/unit/pkgmgr/core/config/test_load.py index 8bb3c25..4ff0198 100644 --- a/tests/unit/pkgmgr/core/config/test_load.py +++ b/tests/unit/pkgmgr/core/config/test_load.py @@ -242,9 +242,7 @@ class LoadConfigIntegrationUnitTests(unittest.TestCase): # Provide package defaults via fake pkgmgr + pkg_root/config root = Path(td) / "site-packages" pkg_root = root / "pkgmgr" - cfg_dir = ( - root / "config" - ) # NOTE: load.py checks multiple roots, including pkg_root.parent (=site-packages) + cfg_dir = pkg_root / "config" pkg_root.mkdir(parents=True) cfg_dir.mkdir(parents=True)