From d4be59b794e1808f1c936deaf6c4afc0a68bbfa4 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Fri, 15 Nov 2024 14:14:06 +0100 Subject: [PATCH] Fix running unit tests without root privileges We need to patch some more calls after recent changes to the LVM populator helper. --- tests/unit_tests/populator_test.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/populator_test.py b/tests/unit_tests/populator_test.py index c4101eb63..872de5cfd 100644 --- a/tests/unit_tests/populator_test.py +++ b/tests/unit_tests/populator_test.py @@ -269,6 +269,8 @@ def test_run(self, *args): class LVMDevicePopulatorTestCase(PopulatorHelperTestCase): helper_class = LVMDevicePopulator + @patch("blivet.tasks.availability.BLOCKDEV_LVM_TECH.availability_errors", return_value=[]) + @patch("blivet.tasks.availability.BLOCKDEV_LVM_PLUGIN._availability_errors", []) @patch("blivet.udev.device_is_dm_lvm", return_value=True) def test_match(self, *args): """Test matching of lvm device populator.""" @@ -277,6 +279,8 @@ def test_match(self, *args): device_is_dm_lvm.return_value = False self.assertFalse(self.helper_class.match(None)) + @patch("blivet.tasks.availability.BLOCKDEV_LVM_TECH.availability_errors", return_value=[]) + @patch("blivet.tasks.availability.BLOCKDEV_LVM_PLUGIN._availability_errors", []) @patch("blivet.udev.device_is_dm", return_value=False) @patch("blivet.udev.device_is_dm_mpath", return_value=False) @patch("blivet.udev.device_is_loop", return_value=False) @@ -862,7 +866,10 @@ class FormatPopulatorTestCase(PopulatorHelperTestCase): def helper_name(self): return self.helper_class.__name__ - def test_match(self): + @patch("blivet.tasks.availability.BLOCKDEV_LVM_TECH.availability_errors", return_value=[]) + @patch("blivet.tasks.availability.BLOCKDEV_LVM_PLUGIN._availability_errors", []) + # pylint: disable=unused-argument + def test_match(self, *args): if self.udev_type is None: return @@ -873,6 +880,8 @@ def test_match(self): self.assertTrue(self.helper_class.match(data, device), msg="Failed to match %s against %s" % (self.udev_type, self.helper_name)) + @patch("blivet.tasks.availability.BLOCKDEV_LVM_TECH.availability_errors", return_value=[]) + @patch("blivet.tasks.availability.BLOCKDEV_LVM_PLUGIN._availability_errors", []) @patch("blivet.static_data.mpath_members.is_mpath_member", return_value=False) @patch("blivet.udev.device_is_partition", return_value=False) @patch("blivet.udev.device_is_dm_partition", return_value=False)