[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
This commit is contained in:
parent
8541266e14
commit
21b898f9db
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user