Merge "Raise ConfigFilesNotFoundError if CONF.api_paste_config not found"
This commit is contained in:
commit
f3fe7fa575
@ -132,12 +132,15 @@ def load_paste_app(app_name):
|
||||
"""Builds and returns a WSGI app from a paste config file.
|
||||
|
||||
:param app_name: Name of the application to load
|
||||
:raises RuntimeError when config file cannot be located or application
|
||||
cannot be loaded from config file
|
||||
:raises ConfigFilesNotFoundError when config file cannot be located
|
||||
:raises RuntimeError when application cannot be loaded from config file
|
||||
"""
|
||||
|
||||
config_path = os.path.abspath(cfg.CONF.find_file(
|
||||
cfg.CONF.api_paste_config))
|
||||
config_path = cfg.CONF.find_file(cfg.CONF.api_paste_config)
|
||||
if not config_path:
|
||||
raise cfg.ConfigFilesNotFoundError(
|
||||
config_files=[cfg.CONF.api_paste_config])
|
||||
config_path = os.path.abspath(config_path)
|
||||
LOG.info(_("Config paste file: %s"), config_path)
|
||||
|
||||
try:
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import os
|
||||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
|
||||
from neutron.common import config # noqa
|
||||
@ -44,3 +45,11 @@ class ConfigurationTest(base.BaseTestCase):
|
||||
self.assertEqual(86400, cfg.CONF.dhcp_lease_duration)
|
||||
self.assertFalse(cfg.CONF.allow_overlapping_ips)
|
||||
self.assertEqual('neutron', cfg.CONF.control_exchange)
|
||||
|
||||
def test_load_paste_app_not_found(self):
|
||||
self.config(api_paste_config='no_such_file.conf')
|
||||
with mock.patch.object(cfg.CONF, 'find_file', return_value=None) as ff:
|
||||
e = self.assertRaises(cfg.ConfigFilesNotFoundError,
|
||||
config.load_paste_app, 'app')
|
||||
ff.assert_called_once_with('no_such_file.conf')
|
||||
self.assertEqual(['no_such_file.conf'], e.config_files)
|
||||
|
Loading…
Reference in New Issue
Block a user