Skip to content

Commit

Permalink
Merge pull request #1319 from vojtechtrefny/main_tests-root-fix
Browse files Browse the repository at this point in the history
Fix running unit tests without root privileges
  • Loading branch information
vojtechtrefny authored Nov 19, 2024
2 parents 6c9f40c + d4be59b commit 7f15753
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/unit_tests/populator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 7f15753

Please sign in to comment.