Merge "Update os.path.remove as it does not exist" into stable/liberty

This commit is contained in:
Jenkins 2015-12-15 21:00:01 +00:00 committed by Gerrit Code Review
commit b084b61294
2 changed files with 17 additions and 1 deletions

View File

@ -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):

View File

@ -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')