Update os.path.remove as it does not exist

Os.path.remove does not exist so this removes it and replaces it with
some code that will remove the file. Functionally fulfilling the role
that os.path.remove was meant to fill.

Change-Id: I040d445007055b31561a592dd74b3e2ffaa9cd54
Closes-bug: 1507564
(cherry picked from commit 36f5ff5632)
This commit is contained in:
NiallBunting 2015-11-04 13:30:18 +00:00 committed by Flavio Percoco
parent 3b3c8ac29b
commit 0bac2bf693
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')