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 = formats.get_format("biosboot") # mountpoints must exist for updateKSData to run mock_devices.return_value = [biosboot_device_obj] mock_mountpoints.values.return_value = [] # initialize ksdata ksdata = makeVersion() biosboot_blivet_obj = InstallerStorage() update_storage_ksdata(biosboot_blivet_obj, ksdata) self.assertIn("part biosboot", str(ksdata))
def test_biosboot_bootloader_in_kickstart(self, mock_mountpoints, mock_devices, dbus): """Test that a biosboot bootloader shows up in the ks data.""" # disable other partitioning modules dbus.return_value.Enabled = False # set up biosboot partition biosboot_device_obj = PartitionDevice("biosboot_partition_device") biosboot_device_obj.size = Size('1MiB') biosboot_device_obj.format = formats.get_format("biosboot") # mountpoints must exist for updateKSData to run mock_devices.return_value = [biosboot_device_obj] mock_mountpoints.values.return_value = [] # initialize ksdata ksdata = makeVersion() biosboot_blivet_obj = InstallerStorage() update_storage_ksdata(biosboot_blivet_obj, ksdata) self.assertIn("part biosboot", str(ksdata))
def test_prepboot_bootloader_in_kickstart(self, mock_mountpoints, mock_bootloader_device, dbus): """Test that a prepboot bootloader shows up in the ks data.""" # disable other partitioning modules dbus.return_value.Enabled = False # set up prepboot partition bootloader_device_obj = PartitionDevice("test_partition_device") bootloader_device_obj.size = Size('5 MiB') bootloader_device_obj.format = formats.get_format("prepboot") # mountpoints must exist for update_ksdata to run mock_bootloader_device.return_value = bootloader_device_obj mock_mountpoints.values.return_value = [] # initialize ksdata ksdata = makeVersion() prepboot_blivet_obj = InstallerStorage() update_storage_ksdata(prepboot_blivet_obj, ksdata) self.assertIn("part prepboot", str(ksdata))
def _run(self): from blivet.errors import StorageError # Set up disks/blivet. try: # Parse the kickstart using anaconda's parser, since it has more # advanced error detection. This also requires having storage set # up first. parser = AnacondaKSParser(AnacondaKSHandler()) parser.readKickstartFromString(self.ks) self.setupDisks(parser.handler) do_kickstart_storage(self._storage, parser.handler) update_storage_ksdata(self._storage, parser.handler) self._storage.devicetree.teardown_all() self._storage.do_it() except (BootLoaderError, KickstartError, StorageError) as e: # anaconda handles expected kickstart errors (like parsing busted # input files) by printing the error and quitting. For testing, an # error might be expected so we should compare the result here with # what is expected. if self.expectedExceptionType and isinstance(e, self.expectedExceptionType): # We expected an exception, and we got one of the correct type. # If it also contains the string we were expecting, then the # test case passes. Otherwise, it's a failure. if self.expectedExceptionText and self._text_matches(str(e)): return else: raise FailedTest(str(e), self.expectedExceptionText) else: # We either got an exception when we were not expecting one, # or we got one of a type other than what we were expecting. # Either of these cases indicates a failure of the test case. raise FailedTest(e, self.expectedExceptionType) finally: self.tearDownDisks() if self.expectedExceptionType: raise FailedTest(None, self.expectedExceptionType)
def _run(self): # Set up disks/blivet. try: # Parse the kickstart using anaconda's parser, since it has more # advanced error detection. This also requires having storage set # up first. parser = AnacondaKSParser(AnacondaKSHandler()) parser.readKickstartFromString(self.ks) self.setupDisks(parser.handler) configure_storage(self._storage, parser.handler) update_storage_ksdata(self._storage, parser.handler) self._storage.devicetree.teardown_all() self._storage.do_it() except (StorageConfigurationError, BootloaderConfigurationError) as e: # anaconda handles expected kickstart errors (like parsing busted # input files) by printing the error and quitting. For testing, an # error might be expected so we should compare the result here with # what is expected. if self.expectedExceptionType and isinstance(e, self.expectedExceptionType): # We expected an exception, and we got one of the correct type. # If it also contains the string we were expecting, then the # test case passes. Otherwise, it's a failure. if self.expectedExceptionText and self._text_matches(str(e)): return else: raise FailedTest(str(e), self.expectedExceptionText) else: # We either got an exception when we were not expecting one, # or we got one of a type other than what we were expecting. # Either of these cases indicates a failure of the test case. raise FailedTest(e, self.expectedExceptionType) finally: self.tearDownDisks() if self.expectedExceptionType: raise FailedTest(None, self.expectedExceptionType)