Fix files actions run() method
New run() method receives a context, which wasn't accounted for in the initial submission. Change-Id: I8a166a54e7f715437cec15c076377500b9f138f9
This commit is contained in:
parent
e62c095324
commit
6dce323726
@ -28,7 +28,7 @@ class FileExists(base.Action):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def run(self):
|
||||
def run(self, context):
|
||||
if (isinstance(self.path, six.string_types) and
|
||||
os.path.exists(self.path)):
|
||||
msg = "Found file %s" % self.path
|
||||
@ -48,7 +48,7 @@ class MakeTempDir(base.Action):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
def run(self, context):
|
||||
try:
|
||||
_path = tempfile.mkdtemp(dir='/tmp/',
|
||||
prefix='file-mistral-action')
|
||||
@ -67,7 +67,7 @@ class RemoveTempDir(base.Action):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
def run(self):
|
||||
def run(self, context):
|
||||
# regex from tempfile's _RandomNameSequence characters
|
||||
_regex = '^/tmp/file-mistral-action[A-Za-z0-9_]{6}$'
|
||||
if (not isinstance(self.path, six.string_types) or
|
||||
|
@ -28,7 +28,7 @@ class FileExistsTest(base.TestCase):
|
||||
def test_file_exists(self, mock_exists):
|
||||
mock_exists.return_value = True
|
||||
action = files.FileExists(self.path)
|
||||
action_result = action.run()
|
||||
action_result = action.run(context={})
|
||||
self.assertFalse(action_result.cancel)
|
||||
self.assertIsNone(action_result.error)
|
||||
self.assertEqual('Found file /etc/issue',
|
||||
@ -44,7 +44,7 @@ class MakeTempDirTest(base.TestCase):
|
||||
def test_make_temp_dir(self, mock_mkdtemp):
|
||||
mock_mkdtemp.return_value = "/tmp/file-mistral-actionxFLfYz"
|
||||
action = files.MakeTempDir()
|
||||
action_result = action.run()
|
||||
action_result = action.run(context={})
|
||||
self.assertFalse(action_result.cancel)
|
||||
self.assertIsNone(action_result.error)
|
||||
self.assertEqual('/tmp/file-mistral-actionxFLfYz',
|
||||
@ -61,7 +61,7 @@ class RemoveTempDirTest(base.TestCase):
|
||||
def test_sucess_remove_temp_dir(self, mock_rmtree):
|
||||
mock_rmtree.return_value = None # rmtree has no return value
|
||||
action = files.RemoveTempDir(self.path)
|
||||
action_result = action.run()
|
||||
action_result = action.run(context={})
|
||||
self.assertFalse(action_result.cancel)
|
||||
self.assertIsNone(action_result.error)
|
||||
self.assertEqual('Deleted directory /tmp/file-mistral-actionxFLfYz',
|
||||
|
Loading…
Reference in New Issue
Block a user