示例#1
0
    def set_up_with_tasks(self):
        """Set up the installation source for installation.

        :return: list of tasks required for the source setup
        :rtype: [Task]
        """
        task = SetUpLiveOSSourceTask(self._image_path, INSTALL_TREE)
        return [task]
    def setup_install_source_task_name_test(self):
        """Test Live OS Source setup installation source task name."""
        task = SetUpLiveOSSourceTask(
                "/path/to/base/image",
                "/path/to/mount/source/image"
            )

        self.assertEqual(task.name, "Set up Live OS Installation Source")
示例#3
0
    def set_up_with_tasks(self):
        """Set up the installation source for installation.

        :return: list of tasks required for the source setup
        :rtype: [Task]
        """
        return [
            SetUpLiveOSSourceTask(image_path=self.image_path,
                                  target_mount=self.mount_point)
        ]
    def setup_install_source_task_missing_image_test(self, proxy_getter):
        """Test Live OS Source setup installation source task missing image error."""
        device_tree = Mock()
        proxy_getter.return_value = device_tree
        device_tree.ResolveDevice = Mock()
        device_tree.ResolveDevice.return_value = ""

        with self.assertRaises(SourceSetupError,
                               msg="Failed to find liveOS image!"):
            SetUpLiveOSSourceTask("/path/to/base/image",
                                  "/path/to/mount/source/image").run()
    def test_setup_install_source_task_missing_image(self, proxy_getter):
        """Test Live OS Source setup installation source task missing image error."""
        device_tree = Mock()
        proxy_getter.return_value = device_tree
        device_tree.ResolveDevice = Mock()
        device_tree.ResolveDevice.return_value = ""

        with pytest.raises(SourceSetupError) as cm:
            SetUpLiveOSSourceTask("/path/to/base/image",
                                  "/path/to/mount/source/image").run()

        assert str(cm.value) == "Failed to resolve the Live OS image."
    def setup_install_source_task_failed_to_mount_test(self, proxy_getter, os_stat, stat, mount):
        """Test Live OS Source setup installation source task mount error."""
        device_tree = Mock()
        proxy_getter.return_value = device_tree
        device_tree.ResolveDevice = Mock()
        device_tree.ResolveDevice.return_value = "resolvedDeviceName"

        device = DeviceData()
        device.path = "/resolved/path/to/base/image"

        device_tree.GetDeviceData = Mock()
        device_tree.GetDeviceData.return_value = DeviceData.to_structure(device)

        mount.return_value = -20

        with self.assertRaises(SourceSetupError, msg="Failed to mount the install tree"):
            SetUpLiveOSSourceTask(
                "/path/to/base/image",
                "/path/to/mount/source/image"
            ).run()
示例#7
0
    def test_setup_install_source_task_invalid_block_dev(
            self, proxy_getter, os_stat, stat_mock):
        """Test Live OS Source setup installation source task with invalid block device error."""
        device_tree = Mock()
        proxy_getter.return_value = device_tree
        device_tree.ResolveDevice = Mock()
        device_tree.ResolveDevice.return_value = "resolvedDeviceName"

        device = DeviceData()
        device.path = "/resolved/path/to/base/image"

        device_tree.GetDeviceData = Mock()
        device_tree.GetDeviceData.return_value = DeviceData.to_structure(
            device)

        stat_mock.S_ISBLK = Mock()
        stat_mock.S_ISBLK.return_value = False

        with pytest.raises(SourceSetupError):
            SetUpLiveOSSourceTask("/path/to/base/image",
                                  "/path/to/mount/source/image").run()
    def test_setup_install_source_task_failed_to_mount(self, proxy_getter,
                                                       os_stat, stat, mount):
        """Test Live OS Source setup installation source task mount error."""
        device_tree = Mock()
        proxy_getter.return_value = device_tree
        device_tree.ResolveDevice = Mock()
        device_tree.ResolveDevice.return_value = "dev1"

        device = DeviceData()
        device.path = "/dev/dev1"

        device_tree.GetDeviceData = Mock()
        device_tree.GetDeviceData.return_value = DeviceData.to_structure(
            device)

        mount.return_value = -20

        with pytest.raises(SourceSetupError) as cm:
            SetUpLiveOSSourceTask("/path/to/base/image",
                                  "/path/to/mount/source/image").run()

        assert str(cm.value) == "Failed to mount the Live OS image."
    def setup_install_source_task_run_test(self, proxy_getter, os_stat, stat, mount):
        """Test Live OS Source setup installation source task run."""
        device_tree = Mock()
        proxy_getter.return_value = device_tree
        device_tree.ResolveDevice = Mock()
        device_tree.ResolveDevice.return_value = "resolvedDeviceName"

        device = DeviceData()
        device.path = "/resolved/path/to/base/image"

        device_tree.GetDeviceData = Mock()
        device_tree.GetDeviceData.return_value = DeviceData.to_structure(device)

        mount.return_value = 0

        SetUpLiveOSSourceTask(
            "/path/to/base/image",
            "/path/to/mount/source/image"
        ).run()

        device_tree.ResolveDevice.assert_called_once_with("/path/to/base/image")
        os_stat.assert_called_once_with("/resolved/path/to/base/image")
    def test_setup_install_source_task_name(self):
        """Test Live OS Source setup installation source task name."""
        task = SetUpLiveOSSourceTask("/path/to/base/image",
                                     "/path/to/mount/source/image")

        assert task.name == "Set up a Live OS image"