Exemple #1
0
class CustomPartitioningInterfaceTestCase(unittest.TestCase):
    """Test DBus interface of the custom partitioning module."""
    def setUp(self):
        """Set up the module."""
        self.module = CustomPartitioningModule()
        self.interface = CustomPartitioningInterface(self.module)

    def publication_test(self):
        """Test the DBus representation."""
        self.assertIsInstance(self.module.for_publication(),
                              CustomPartitioningInterface)

    def data_test(self, ):
        """Test the data property."""
        with self.assertRaises(UnavailableDataError):
            if self.module.data:
                self.fail("The data should not be available.")

        data = Mock()
        self.module.process_kickstart(data)
        self.assertEqual(self.module.data, data)

    @patch_dbus_publish_object
    def configure_with_task_test(self, publisher):
        """Test ConfigureWithTask."""
        self.module.on_storage_reset(Mock())
        self.module.process_kickstart(Mock())
        task_path = self.interface.ConfigureWithTask()

        obj = check_task_creation(self, task_path, publisher,
                                  CustomPartitioningTask)

        self.assertEqual(obj.implementation._storage, self.module.storage)
Exemple #2
0
    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)
Exemple #3
0
 def setUp(self):
     """Set up the module."""
     self.module = CustomPartitioningModule()
     self.interface = CustomPartitioningInterface(self.module)
Exemple #4
0
class CustomPartitioningKickstartTestCase(unittest.TestCase):
    """Test the custom partitioning module with kickstart."""
    def setUp(self):
        """Set up the module."""
        self.module = CustomPartitioningModule()
        self.interface = CustomPartitioningInterface(self.module)

    def _process_kickstart(self, ks_in):
        """Process the kickstart."""
        storage_module = StorageModule()
        handler = storage_module.get_kickstart_handler()
        parser = storage_module.get_kickstart_parser(handler)
        parser.readKickstartFromString(ks_in)
        self.module.process_kickstart(handler)

    def _setup_kickstart(self):
        """Set up the kickstart."""
        storage_module = StorageModule()
        handler = storage_module.get_kickstart_handler()
        self.module.setup_kickstart(handler)
        return handler

    @patch_dbus_publish_object
    def requires_passphrase_test(self, publisher):
        """Test RequiresPassphrase."""
        self._process_kickstart("part /")
        self.assertEqual(self.interface.RequiresPassphrase(), False)
        self._process_kickstart("part / --encrypted")
        self.assertEqual(self.interface.RequiresPassphrase(), True)
        self.interface.SetPassphrase("123456")
        self.assertEqual(self.interface.RequiresPassphrase(), False)

    @patch('pyanaconda.dbus.DBus.get_proxy')
    @patch('pyanaconda.storage.osinstall.InstallerStorage.mountpoints',
           new_callable=PropertyMock)
    def test_prepboot_bootloader_in_kickstart(self, mock_mountpoints, dbus):
        """Test that a prepboot bootloader shows up in the ks data."""
        # set up prepboot partition
        bootloader_device_obj = PartitionDevice("test_partition_device")
        bootloader_device_obj.size = Size('5 MiB')
        bootloader_device_obj.format = get_format("prepboot")

        # mountpoints must exist for update_ksdata to run
        mock_mountpoints.values.return_value = []

        # set up the storage
        self.module.on_storage_reset(create_storage())
        self.assertTrue(self.module.storage)

        self.module.storage.bootloader.stage1_device = bootloader_device_obj

        # initialize ksdata
        ksdata = self._setup_kickstart()
        self.assertIn("part prepboot", str(ksdata))

    @patch('pyanaconda.dbus.DBus.get_proxy')
    @patch('pyanaconda.storage.osinstall.InstallerStorage.devices',
           new_callable=PropertyMock)
    @patch('pyanaconda.storage.osinstall.InstallerStorage.mountpoints',
           new_callable=PropertyMock)
    def test_biosboot_bootloader_in_kickstart(self, mock_mountpoints,
                                              mock_devices, dbus):
        """Test that a biosboot bootloader shows up in the ks data."""
        # set up biosboot partition
        biosboot_device_obj = PartitionDevice("biosboot_partition_device")
        biosboot_device_obj.size = Size('1MiB')
        biosboot_device_obj.format = get_format("biosboot")

        # mountpoints must exist for updateKSData to run
        mock_devices.return_value = [biosboot_device_obj]
        mock_mountpoints.values.return_value = []

        # set up the storage
        self.module.on_storage_reset(create_storage())
        self.assertTrue(self.module.storage)

        # initialize ksdata
        ksdata = self._setup_kickstart()
        self.assertIn("part biosboot", str(ksdata))