Exemple #1
0
 def setup(self, mock_path):
     mock_path.return_value = True
     self.device_provider = mock.Mock()
     self.device_provider.is_loop = mock.Mock()
     self.device = MappedDevice(
         '/dev/foo', self.device_provider
     )
Exemple #2
0
class TestMappedDevice(object):
    @patch('os.path.exists')
    def setup(self, mock_path):
        mock_path.return_value = True
        self.device_provider = mock.Mock()
        self.device_provider.is_loop = mock.Mock()
        self.device = MappedDevice('/dev/foo', self.device_provider)

    @patch('os.path.exists')
    @raises(KiwiMappedDeviceError)
    def test_device_not_existingr(self, mock_path):
        mock_path.return_value = False
        MappedDevice('/dev/foo', mock.Mock())

    def test_get_device(self):
        assert self.device.get_device() == '/dev/foo'

    def test_is_loop(self):
        assert self.device.is_loop() == self.device_provider.is_loop()
Exemple #3
0
class TestMappedDevice(object):
    @patch('os.path.exists')
    def setup(self, mock_path):
        mock_path.return_value = True
        self.device_provider = mock.Mock()
        self.device_provider.is_loop = mock.Mock()
        self.device = MappedDevice(
            '/dev/foo', self.device_provider
        )

    @patch('os.path.exists')
    @raises(KiwiMappedDeviceError)
    def test_device_not_existingr(self, mock_path):
        mock_path.return_value = False
        MappedDevice('/dev/foo', mock.Mock())

    def test_get_device(self):
        assert self.device.get_device() == '/dev/foo'

    def test_is_loop(self):
        assert self.device.is_loop() == self.device_provider.is_loop()
Exemple #4
0
 def setup(self, mock_machine, mock_exists):
     mock_machine.return_value = 'x86_64'
     mock_exists.return_value = True
     description = XMLDescription(
         '../data/example_disk_config.xml'
     )
     self.device_map = {
         'root': MappedDevice('/dev/root-device', mock.Mock()),
         'boot': MappedDevice('/dev/boot-device', mock.Mock()),
         'efi': MappedDevice('/dev/efi-device', mock.Mock())
     }
     self.id_map = {
         'kiwi_RootPart': 1,
         'kiwi_BootPart': 1
     }
     self.id_map_sorted = OrderedDict(
         sorted(self.id_map.items())
     )
     self.loop_provider = mock.Mock()
     kiwi.disk_builder.LoopDevice = mock.Mock(
         return_value=self.loop_provider
     )
     self.disk = mock.Mock()
     provider = mock.Mock()
     provider.get_device = mock.Mock(
         return_value='/dev/some-loop'
     )
     self.disk.storage_provider = provider
     self.partitioner = mock.Mock()
     self.partitioner.get_id = mock.Mock(
         return_value=1
     )
     self.disk.partitioner = self.partitioner
     self.disk.get_uuid = mock.Mock(
         return_value='0815'
     )
     self.disk.get_partition_id_map = mock.Mock(
         return_value=self.id_map_sorted
     )
     self.disk.get_device = mock.Mock(
         return_value=self.device_map
     )
     self.kernel = mock.Mock()
     self.kernel.get_kernel = mock.Mock()
     self.kernel.get_xen_hypervisor = mock.Mock()
     self.kernel.copy_kernel = mock.Mock()
     self.kernel.copy_xen_hypervisor = mock.Mock()
     kiwi.disk_builder.Kernel = mock.Mock(
         return_value=self.kernel
     )
     self.disk_format = mock.Mock()
     self.disk_format.get_target_name_for_format = mock.Mock(
         return_value='some-target-format-name'
     )
     kiwi.disk_builder.DiskFormat = mock.Mock(
         return_value=self.disk_format
     )
     kiwi.disk_builder.Disk = mock.Mock(
         return_value=self.disk
     )
     self.disk_setup = mock.Mock()
     self.disk_setup.get_efi_label = mock.Mock(
         return_value='EFI'
     )
     self.disk_setup.get_root_label = mock.Mock(
         return_value='ROOT'
     )
     self.disk_setup.get_boot_label = mock.Mock(
         return_value='BOOT'
     )
     self.disk_setup.need_boot_partition = mock.Mock(
         return_value=True
     )
     self.bootloader_install = mock.Mock()
     kiwi.disk_builder.BootLoaderInstall = mock.MagicMock(
         return_value=self.bootloader_install
     )
     self.bootloader_config = mock.Mock()
     kiwi.disk_builder.BootLoaderConfig = mock.MagicMock(
         return_value=self.bootloader_config
     )
     kiwi.disk_builder.DiskSetup = mock.MagicMock(
         return_value=self.disk_setup
     )
     self.boot_image_task = mock.Mock()
     self.boot_image_task.boot_root_directory = 'boot_dir'
     self.boot_image_task.kernel_filename = 'kernel'
     self.boot_image_task.initrd_filename = 'initrd'
     self.boot_image_task.xen_hypervisor_filename = 'xen_hypervisor'
     kiwi.disk_builder.BootImageTask = mock.Mock(
         return_value=self.boot_image_task
     )
     self.firmware = mock.Mock()
     self.firmware.efi_mode = mock.Mock(
         return_value='efi'
     )
     kiwi.disk_builder.FirmWare = mock.Mock(
         return_value=self.firmware
     )
     self.system_setup = mock.Mock()
     kiwi.disk_builder.SystemSetup = mock.Mock(
         return_value=self.system_setup
     )
     self.install_image = mock.Mock()
     kiwi.disk_builder.InstallImageBuilder = mock.Mock(
         return_value=self.install_image
     )
     self.raid_root = mock.Mock()
     kiwi.disk_builder.RaidDevice = mock.Mock(
         return_value=self.raid_root
     )
     self.luks_root = mock.Mock()
     kiwi.disk_builder.LuksDevice = mock.Mock(
         return_value=self.luks_root
     )
     self.disk_builder = DiskBuilder(
         XMLState(description.load()), 'target_dir', 'root_dir'
     )
     self.disk_builder.build_type_name = 'oem'
     self.machine = mock.Mock()
     self.machine.get_domain = mock.Mock(
         return_value='dom0'
     )
     self.disk_builder.machine = self.machine
     self.disk_builder.image_format = None
Exemple #5
0
 def test_device_not_existingr(self, mock_path):
     mock_path.return_value = False
     MappedDevice('/dev/foo', mock.Mock())
Exemple #6
0
 def setup(self, mock_path):
     mock_path.return_value = True
     self.device_provider = mock.Mock()
     self.device_provider.is_loop = mock.Mock()
     self.device = MappedDevice('/dev/foo', self.device_provider)