Comments (4)
One option would be to mask the mount cache while running the action tests, eg:
diff --git a/tests/storagetestcase.py b/tests/storagetestcase.py
index ad1216f..427a19c 100644
--- a/tests/storagetestcase.py
+++ b/tests/storagetestcase.py
@@ -69,6 +69,12 @@ class StorageTestCase(unittest.TestCase):
self.partition_probe = PartitionDevice.probe
PartitionDevice.probe = partition_probe
+ def nada():
+ pass
+
+ self.get_active_mounts = blivet.formats.fs.mountsCache._getActiveMounts
+ blivet.formats.fs.mountsCache._getActiveMounts = nada
+
def tearDown(self):
blivet.devices.StorageDevice.status = self.storage_status
blivet.devices.DMDevice.status = self.dm_status
@@ -84,6 +90,8 @@ class StorageTestCase(unittest.TestCase):
blivet.devices.PartitionDevice.probe = self.partition_probe
+ blivet.formats.fs.mountsCache._getActiveMounts = self.get_active_mounts
+
def newDevice(self, *args, **kwargs):
""" Return a new Device instance suitable for testing. """
device_class = kwargs.pop("device_class")
Another option would be to adjust the names of those disks/partitions, eg:
diff --git a/tests/action_test.py b/tests/action_test.py
index 00d63ad..bafec96 100644
--- a/tests/action_test.py
+++ b/tests/action_test.py
@@ -34,7 +34,7 @@ class DeviceActionTestCase(StorageTestCase):
"""
super(DeviceActionTestCase, self).setUp()
- for name in ["sda", "sdb", "sdc", "sdd"]:
+ for name in ["mocksda", "mocksdb", "mocksdc", "mocksdd"]:
disk = self.newDevice(device_class=DiskDevice,
name=name, size=Size("100 GiB"))
disk.format = self.newFormat("disklabel", path=disk.path,
@@ -42,11 +42,11 @@ class DeviceActionTestCase(StorageTestCase):
self.storage.devicetree._addDevice(disk)
# create a layout similar to autopart as a starting point
- sda = self.storage.devicetree.getDeviceByName("sda")
- sdb = self.storage.devicetree.getDeviceByName("sdb")
+ sda = self.storage.devicetree.getDeviceByName("mocksda")
+ sdb = self.storage.devicetree.getDeviceByName("mocksdb")
sda1 = self.newDevice(device_class=PartitionDevice,
- exists=True, name="sda1", parents=[sda],
+ exists=True, name="mocksda1", parents=[sda],
size=Size("500 MiB"))
sda1.format = self.newFormat("ext4", mountpoint="/boot",
device_instance=sda1,
@@ -54,13 +54,13 @@ class DeviceActionTestCase(StorageTestCase):
self.storage.devicetree._addDevice(sda1)
sda2 = self.newDevice(device_class=PartitionDevice,
- size=Size("99.5 GiB"), name="sda2",
+ size=Size("99.5 GiB"), name="mocksda2",
parents=[sda], exists=True)
sda2.format = self.newFormat("lvmpv", device=sda2.path, exists=True)
self.storage.devicetree._addDevice(sda2)
sdb1 = self.newDevice(device_class=PartitionDevice,
- size=Size("99.999 GiB"), name="sdb1",
+ size=Size("99.999 GiB"), name="mocksdb1",
parents=[sdb], exists=True)
sdb1.format = self.newFormat("lvmpv", device=sdb1.path, exists=True)
self.storage.devicetree._addDevice(sdb1)
Which seems preferable?
from blivet.
It is hard for me to say. You already set the status property of lots of Device* methods to False; perhaps that is another reasonable option.
from blivet.
I am for the former suggested approach except that it should use python-mock
and Mock instance(s). I've created many unit tests for the oscap-anaconda-addon that use Mock quite heavily and it was really worth it. See for example https://github.com/OpenSCAP/oscap-anaconda-addon/blob/master/tests/common_test.py
from blivet.
Fixed by 4627e65
from blivet.
Related Issues (20)
- Separate actions for LVM cache attach/detach
- Add support for enabling/disabling compression/deduplication for existing LVM VDO volumes HOT 1
- Add support for LVM RAID with integrity
- Make sure libblockdev exceptions are not raised from Blivet
- Consider using --subvolid when deleting subvolumes HOT 1
- Add support for LVM writecache HOT 1
- Report error when trying to use uninitialized disk in device factory HOT 1
- Cannot add a newly created PV to an existing VG with active LVs HOT 1
- 3.4.3: pep517 based build and instyall places files in incorrect locations HOT 1
- Determine CPU architecture & choose appropriate algorithm for BTRFS partitions
- Please add f2fs multi-drive support
- Debian Testing 6.0.8-1 : Failed to init blivet: None of ext4,xfs,ext3,ext2 is supported by your kernel HOT 6
- Hardware without AES-NI: use xchacha12/Adiantum instead of AES-XTS HOT 12
- if the file system is damaged, resize2fs may get stuck
- DeviceTree.resolve_device() returns a btrfs volume even in case reqested subvolume is not found
- Cannot install F38 on efi macs ( "macefi" vs "efi" issue ) HOT 1
- Improve performance and achieve interim solution for #1108 : Change default from AES256 to AES128 (or SHA256 to SHA512) HOT 2
- Logging to `/tmp/lvm.log` without cleanup HOT 1
- Data and Metadata RAID level not set for existing btrfs volumes
- Very slow start HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blivet.