Пример #1
0
    def setUp(self):
        """Set up the module."""
        self.storage_module = StorageModule()
        self.storage_interface = StorageInterface(self.storage_module)

        self.module = self.storage_module._custom_part_module
        self.interface = CustomPartitioningInterface(self.module)
Пример #2
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)
Пример #3
0
class CustomPartitioningKickstartTestCase(unittest.TestCase):
    """Test the custom partitioning module with kickstart."""
    def setUp(self):
        """Set up the module."""
        self.storage_module = StorageModule()
        self.storage_interface = StorageInterface(self.storage_module)

        self.module = self.storage_module._custom_part_module
        self.interface = CustomPartitioningInterface(self.module)

    def _process_kickstart(self, ks_in):
        check_kickstart_interface(self, self.storage_interface, ks_in)

    def requires_passphrase_test(self):
        """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)
Пример #4
0
 def setUp(self):
     """Set up the module."""
     self.module = CustomPartitioningModule()
     self.interface = CustomPartitioningInterface(self.module)
Пример #5
0
 def for_publication(self):
     """Return a DBus representation."""
     return CustomPartitioningInterface(self)
Пример #6
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))
Пример #7
0
 def publish(self):
     """Publish the module."""
     DBus.publish_object(CUSTOM_PARTITIONING.object_path,
                         CustomPartitioningInterface(self))