summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glance/async/flows/convert.py2
-rw-r--r--glance/tests/unit/async/flows/test_convert.py16
2 files changed, 17 insertions, 1 deletions
diff --git a/glance/async/flows/convert.py b/glance/async/flows/convert.py
index c4b61dba5..639d82886 100644
--- a/glance/async/flows/convert.py
+++ b/glance/async/flows/convert.py
@@ -96,7 +96,7 @@ class _Convert(task.Task):
fs_path = result.split("file://")[-1]
if os.path.exists(fs_path):
- os.path.remove(fs_path)
+ os.remove(fs_path)
def get_flow(**kwargs):
diff --git a/glance/tests/unit/async/flows/test_convert.py b/glance/tests/unit/async/flows/test_convert.py
index 07cb30c80..672900fc1 100644
--- a/glance/tests/unit/async/flows/test_convert.py
+++ b/glance/tests/unit/async/flows/test_convert.py
@@ -94,6 +94,22 @@ class TestImportTask(test_utils.BaseTestCase):
rm_mock.return_value = None
image_convert.execute(image, 'file:///test/path.raw')
+ 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_import_flow_with_convert_and_introspect(self):
self.config(engine_mode='serial',
group='taskflow_executor')