From 6dce323726c5230057f0b80b176942f6179463c5 Mon Sep 17 00:00:00 2001 From: Giulio Fidente Date: Thu, 29 Jun 2017 13:56:05 +0200 Subject: [PATCH] Fix files actions run() method New run() method receives a context, which wasn't accounted for in the initial submission. Change-Id: I8a166a54e7f715437cec15c076377500b9f138f9 --- tripleo_common/actions/files.py | 6 +++--- tripleo_common/tests/actions/test_files.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tripleo_common/actions/files.py b/tripleo_common/actions/files.py index de7e65ed1..38133b7c3 100644 --- a/tripleo_common/actions/files.py +++ b/tripleo_common/actions/files.py @@ -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 diff --git a/tripleo_common/tests/actions/test_files.py b/tripleo_common/tests/actions/test_files.py index 98bd61fc2..4a6756d71 100644 --- a/tripleo_common/tests/actions/test_files.py +++ b/tripleo_common/tests/actions/test_files.py @@ -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',