class DiskInitializationModuleTestCase(unittest.TestCase): """Test the disk initialization module.""" def setUp(self): """Set up the module.""" self.disk_init_module = DiskInitializationModule() def test_storage_property(self): """Test the storage property.""" with pytest.raises(UnavailableStorageError): assert self.disk_init_module.storage is not None storage = Mock() self.disk_init_module.on_storage_changed(storage) assert self.disk_init_module.storage == storage def test_setup_kickstart(self): """Test setup_kickstart with storage.""" storage = create_storage() data = Mock() self.disk_init_module.on_storage_changed(storage) self.disk_init_module.set_initialization_mode( InitializationMode.CLEAR_NONE) self.disk_init_module.setup_kickstart(data) assert data.clearpart.type == CLEARPART_TYPE_NONE assert data.clearpart.devices == [] assert data.clearpart.drives == []
class DiskInitializationModuleTestCase(unittest.TestCase): """Test the disk initialization module.""" def setUp(self): """Set up the module.""" self.disk_init_module = DiskInitializationModule() def storage_property_test(self): """Test the storage property.""" with self.assertRaises(UnavailableStorageError): self.assertIsNotNone(self.disk_init_module.storage) storage = Mock() self.disk_init_module.on_storage_changed(storage) self.assertEqual(self.disk_init_module.storage, storage) def setup_kickstart_test(self): """Test setup_kickstart with storage.""" storage = create_storage() data = Mock() self.disk_init_module.on_storage_changed(storage) self.disk_init_module.set_initialization_mode(InitializationMode.CLEAR_NONE) self.disk_init_module.setup_kickstart(data) self.assertEqual(data.clearpart.type, CLEARPART_TYPE_NONE) self.assertEqual(data.clearpart.devices, []) self.assertEqual(data.clearpart.drives, [])
class DiskInitializationModuleTestCase(unittest.TestCase): """Test the disk initialization module.""" def setUp(self): """Set up the module.""" self.disk_init_module = DiskInitializationModule() def storage_property_test(self): """Test the storage property.""" with self.assertRaises(UnavailableStorageError): self.assertIsNotNone(self.disk_init_module.storage) storage = Mock() self.disk_init_module.on_storage_reset(storage) self.assertEqual(self.disk_init_module.storage, storage) def setup_kickstart_test(self): """Test setup_kickstart with storage.""" storage = create_storage() data = Mock() self.disk_init_module.on_storage_reset(storage) self.disk_init_module.set_initialization_mode(InitializationMode.CLEAR_NONE) self.disk_init_module.setup_kickstart(data) self.assertEqual(data.clearpart.type, CLEARPART_TYPE_NONE) self.assertEqual(data.clearpart.devices, []) self.assertEqual(data.clearpart.drives, [])
def __init__(self): super().__init__() # We need this so all the /dev/disk/* stuff is set up. udev.trigger(subsystem="block", action="change") self._modules = [] self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module) self._bootloader_module = BootloaderModule() self._add_module(self._bootloader_module) self._auto_part_module = AutoPartitioningModule() self._add_module(self._auto_part_module) self._manual_part_module = ManualPartitioningModule() self._add_module(self._manual_part_module) self._dasd_module = None self._zfcp_module = None if arch.is_s390(): self._dasd_module = DASDModule() self._add_module(self._dasd_module) self._zfcp_module = ZFCPModule() self._add_module(self._zfcp_module)
def __init__(self): super().__init__() # Initialize Blivet. enable_installer_mode() # The storage model. self._storage = None self.storage_changed = Signal() # Initialize modules. self._modules = [] self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module) self._snapshot_module = SnapshotModule() self._add_module(self._snapshot_module) self._bootloader_module = BootloaderModule() self._add_module(self._bootloader_module) self._fcoe_module = FCOEModule() self._add_module(self._fcoe_module) self._nvdimm_module = NVDIMMModule() self._add_module(self._nvdimm_module) self._dasd_module = None self._zfcp_module = None if arch.is_s390(): self._dasd_module = DASDModule() self._add_module(self._dasd_module) self._zfcp_module = ZFCPModule() self._add_module(self._zfcp_module) # Initialize the partitioning modules. self._partitioning_modules = {} self._auto_part_module = AutoPartitioningModule() self._add_partitioning_module(AUTO_PARTITIONING.object_path, self._auto_part_module) self._manual_part_module = ManualPartitioningModule() self._add_partitioning_module(MANUAL_PARTITIONING.object_path, self._manual_part_module) self._custom_part_module = CustomPartitioningModule() self._add_partitioning_module(CUSTOM_PARTITIONING.object_path, self._custom_part_module) # Connect modules to signals. self.storage_changed.connect(self._snapshot_module.on_storage_reset)
def __init__(self): super().__init__() self._modules = [] self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module)
def __init__(self): super().__init__() self._modules = [] self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module) self._bootloader_module = BootloaderModule() self._add_module(self._bootloader_module) self._autopart_module = AutoPartitioningModule() self._add_module(self._autopart_module)
def __init__(self): super().__init__() self._modules = [] self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module) self._bootloader_module = BootloaderModule() self._add_module(self._bootloader_module) self._autopart_module = AutoPartitioningModule() self._add_module(self._autopart_module) if arch.is_s390(): self._dasd_module = DASDModule() self._add_module(self._dasd_module) else: self._dasd_module = None
def __init__(self): super().__init__() # Initialize Blivet. enable_installer_mode() # The storage model. self._current_storage = None self._storage_playground = None self.storage_changed = Signal() # The created partitioning modules. self._created_partitioning = [] self.created_partitioning_changed = Signal() # The applied partitioning module. self._applied_partitioning = None self.applied_partitioning_changed = Signal() self.partitioning_reset = Signal() # Initialize modules. self._modules = [] self._storage_checker_module = StorageCheckerModule() self._add_module(self._storage_checker_module) self._device_tree_module = DeviceTreeModule() self._add_module(self._device_tree_module) self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module) self._snapshot_module = SnapshotModule() self._add_module(self._snapshot_module) self._bootloader_module = BootloaderModule() self._add_module(self._bootloader_module) self._fcoe_module = FCOEModule() self._add_module(self._fcoe_module) self._iscsi_module = ISCSIModule() self._add_module(self._iscsi_module) self._nvdimm_module = NVDIMMModule() self._add_module(self._nvdimm_module) self._dasd_module = DASDModule() self._add_module(self._dasd_module) self._zfcp_module = ZFCPModule() self._add_module(self._zfcp_module) # Connect modules to signals. self.storage_changed.connect( self._device_tree_module.on_storage_changed) self.storage_changed.connect(self._disk_init_module.on_storage_changed) self.storage_changed.connect( self._disk_selection_module.on_storage_changed) self.storage_changed.connect(self._snapshot_module.on_storage_changed) self.storage_changed.connect( self._bootloader_module.on_storage_changed) self.storage_changed.connect(self._dasd_module.on_storage_changed) self._disk_init_module.format_unrecognized_enabled_changed.connect( self._dasd_module.on_format_unrecognized_enabled_changed) self._disk_init_module.format_ldl_enabled_changed.connect( self._dasd_module.on_format_ldl_enabled_changed) self._disk_selection_module.protected_devices_changed.connect( self.on_protected_devices_changed)
def setUp(self): """Set up the module.""" self.disk_init_module = DiskInitializationModule() self.disk_init_interface = DiskInitializationInterface(self.disk_init_module)
def __init__(self): super().__init__() # Initialize Blivet. enable_installer_mode() # The storage model. self._storage = None self.storage_changed = Signal() self.storage_reset = Signal() # The created partitioning modules. self._created_partitioning = [] self.created_partitioning_changed = Signal() # The applied partitioning module. self._applied_partitioning = None self.applied_partitioning_changed = Signal() # Initialize modules. self._modules = [] self._storage_checker_module = StorageCheckerModule() self._add_module(self._storage_checker_module) self._device_tree_module = DeviceTreeModule() self._add_module(self._device_tree_module) self._disk_init_module = DiskInitializationModule() self._add_module(self._disk_init_module) self._disk_selection_module = DiskSelectionModule() self._add_module(self._disk_selection_module) self._snapshot_module = SnapshotModule() self._add_module(self._snapshot_module) self._bootloader_module = BootloaderModule() self._add_module(self._bootloader_module) self._fcoe_module = FCOEModule() self._add_module(self._fcoe_module) self._iscsi_module = ISCSIModule() self._add_module(self._iscsi_module) self._nvdimm_module = NVDIMMModule() self._add_module(self._nvdimm_module) self._dasd_module = None self._zfcp_module = None if arch.is_s390(): self._dasd_module = DASDModule() self._add_module(self._dasd_module) self._zfcp_module = ZFCPModule() self._add_module(self._zfcp_module) # Initialize the partitioning modules. # TODO: Remove the static partitioning modules. self._add_module(self.create_partitioning( PartitioningMethod.AUTOMATIC)) self._add_module(self.create_partitioning(PartitioningMethod.MANUAL)) self._add_module(self.create_partitioning(PartitioningMethod.CUSTOM)) self._add_module( self.create_partitioning(PartitioningMethod.INTERACTIVE)) self._add_module(self.create_partitioning(PartitioningMethod.BLIVET)) # Forget the static partitioning modules. # TODO: Remove with the static partitioning modules. self._created_partitioning = [] # Connect modules to signals. self.storage_changed.connect(self._device_tree_module.on_storage_reset) self.storage_changed.connect(self._disk_init_module.on_storage_reset) self.storage_changed.connect( self._disk_selection_module.on_storage_reset) self.storage_changed.connect(self._snapshot_module.on_storage_reset) self.storage_changed.connect(self._bootloader_module.on_storage_reset) self._disk_selection_module.protected_devices_changed.connect( self.on_protected_devices_changed)
class DiskInitializationInterfaceTestCase(unittest.TestCase): """Test DBus interface of the disk initialization module.""" def setUp(self): """Set up the module.""" self.disk_init_module = DiskInitializationModule() self.disk_init_interface = DiskInitializationInterface(self.disk_init_module) def on_partitioning_changed_test(self): """Smoke test for on_partitioning_changed callback.""" mode_changed_callback = Mock() devices_changed_callback = Mock() drives_changed_callback = Mock() self.disk_init_module.set_initialization_mode(InitializationMode.CLEAR_NONE) self.disk_init_module.initialization_mode_changed.connect(mode_changed_callback) self.disk_init_module.devices_to_clear_changed.connect(devices_changed_callback) self.disk_init_module.drives_to_clear_changed.connect(drives_changed_callback) self.disk_init_module.on_partitioning_changed(create_storage()) mode_changed_callback.called_once_with(InitializationMode.CLEAR_NONE) drives_changed_callback.called_once_with([]) devices_changed_callback.called_once_with([]) def _test_dbus_property(self, *args, **kwargs): check_dbus_property( self, DISK_INITIALIZATION, self.disk_init_interface, *args, **kwargs ) def default_disk_label_property_test(self): """Test the default disk label property.""" self._test_dbus_property( "DefaultDiskLabel", "msdos" ) def format_unrecognized_enabled_property_test(self): """Test the can format unrecognized property.""" self._test_dbus_property( "FormatUnrecognizedEnabled", False ) def can_initialize_label_property_test(self): """Test the can initialize label property.""" self._test_dbus_property( "InitializeLabelsEnabled", False ) def format_ldl_enabled_property_test(self): """Test the can format LDL property.""" self._test_dbus_property( "FormatLDLEnabled", True ) def initialization_mode_property_test(self): """Test the type to clear property.""" self._test_dbus_property( "InitializationMode", CLEAR_PARTITIONS_LINUX ) def devices_to_clear_property_test(self): """Test the devices to clear property.""" self._test_dbus_property( "DevicesToClear", ["sda2", "sda3", "sdb1"] ) def drives_to_clear_property_test(self): """Test the drives to clear property.""" self._test_dbus_property( "DrivesToClear", ["sda", "sdb"] )
def setUp(self): """Set up the module.""" self.disk_init_module = DiskInitializationModule()