Beispiel #1
0
    def test_convert_success(self):
        image_convert = convert._Convert(self.task.task_id, self.task_type,
                                         self.img_repo)

        self.task_repo.get.return_value = self.task
        image_id = mock.sentinel.image_id
        image = mock.MagicMock(image_id=image_id, virtual_size=None)
        self.img_repo.get.return_value = image

        with mock.patch.object(processutils, 'execute') as exc_mock:
            exc_mock.return_value = ("", None)
            image_convert.execute(image, '/test/path.raw')
Beispiel #2
0
    def test_convert_success(self):
        image_convert = convert._Convert(self.task.task_id,
                                         self.task_type,
                                         self.img_repo)

        self.task_repo.get.return_value = self.task
        image_id = mock.sentinel.image_id
        image = mock.MagicMock(image_id=image_id, virtual_size=None)
        self.img_repo.get.return_value = image

        with mock.patch.object(processutils, 'execute') as exc_mock:
            exc_mock.return_value = ("", None)
            image_convert.execute(image, '/test/path.raw')
Beispiel #3
0
    def test_convert_revert_success(self):
        image_convert = convert._Convert(self.task.task_id, self.task_type,
                                         self.img_repo)

        self.task_repo.get.return_value = self.task
        image_id = mock.sentinel.image_id
        image = mock.MagicMock(image_id=image_id, virtual_size=None)
        self.img_repo.get.return_value = image

        with mock.patch.object(processutils, 'execute') as exc_mock:
            exc_mock.return_value = ("", None)
            with mock.patch.object(os, 'remove') as rmtree_mock:
                rmtree_mock.return_value = None
                image_convert.revert(image, 'file:///tmp/test')
    def test_convert_revert_success(self):
        image_convert = convert._Convert(self.task.task_id,
                                         self.task_type,
                                         self.img_repo)

        self.task_repo.get.return_value = self.task
        image_id = mock.sentinel.image_id
        image = mock.MagicMock(image_id=image_id, virtual_size=None)
        self.img_repo.get.return_value = image

        with mock.patch.object(processutils, 'execute') as exc_mock:
            exc_mock.return_value = ("", None)
            with mock.patch.object(os, 'remove') as rmtree_mock:
                rmtree_mock.return_value = None
                image_convert.revert(image, 'file:///tmp/test')
Beispiel #5
0
    def test_convert_success(self):
        image_convert = convert._Convert(self.task.task_id,
                                         self.task_type,
                                         self.img_repo)

        self.task_repo.get.return_value = self.task
        image_id = mock.sentinel.image_id
        image = mock.MagicMock(image_id=image_id, virtual_size=None)
        self.img_repo.get.return_value = image

        with mock.patch.object(processutils, 'execute') as exc_mock:
            exc_mock.return_value = ("", None)
            with mock.patch.object(os, 'rename') as rm_mock:
                rm_mock.return_value = None
                image_convert.execute(image, 'file:///test/path.raw')

                # NOTE(hemanthm): Asserting that the source format is passed
                # to qemu-utis to avoid inferring the image format. This
                # shields us from an attack vector described at
                # https://bugs.launchpad.net/glance/+bug/1449062/comments/72
                self.assertIn('-f', exc_mock.call_args[0])