From 21b898f9db90e72befdd515bc176fbd70a8a12d6 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Fri, 20 Oct 2017 15:58:25 +0100 Subject: [PATCH] [TrivialFix] Fix IOError being thrown by unit test A unit test is raising an IOError [0] because a config file location isn't mocked so the unit test looks for a non-existent file. This PS mocks the location to avoid the error. [0] IOError: [Errno 2] No such file or directory: '/etc/deckhand/deckhand-paste.ini' Change-Id: I2a3aa3f80f5d1b3013d43d9c84a82e583c4384e2 --- .../tests/unit/control/test_api_initialization.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/deckhand/tests/unit/control/test_api_initialization.py b/deckhand/tests/unit/control/test_api_initialization.py index 891a0d2b..108a9cc9 100644 --- a/deckhand/tests/unit/control/test_api_initialization.py +++ b/deckhand/tests/unit/control/test_api_initialization.py @@ -13,6 +13,8 @@ # limitations under the License. import inspect +import os + import mock from deckhand.control import api @@ -39,6 +41,18 @@ class TestApi(test_base.DeckhandTestCase): resource, class_name, autospec=True) setattr(self, utils.to_snake_case(class_name), resource_obj) + # Mock the location of the configuration files for API initialization. + curr_path = os.path.dirname(os.path.realpath(__file__)) + repo_path = os.path.join( + curr_path, os.pardir, os.pardir, os.pardir, os.pardir) + temp_config_files = [ + os.path.join(repo_path, 'etc', 'deckhand', 'deckhand.conf.sample'), + os.path.join(repo_path, 'etc', 'deckhand', 'deckhand-paste.ini') + ] + mock_get_config_files = self.patchobject( + api, '_get_config_files', autospec=True) + mock_get_config_files.return_value = temp_config_files + def _get_module_class_names(self, module): class_names = [obj.__name__ for name, obj in inspect.getmembers(module) if inspect.isclass(obj)]