Support older notifications set_override keys
Neutron and Ceilometer use set_override to set the older deprecated key. We should support them using the ConfFixture Closes-Bug: #1521776 Change-Id: I2bd77284f80bc4525f062f313b1ec74f2b54b395
This commit is contained in:
committed by
Oleksii Zamiatin
parent
ba42571b5a
commit
b6ad95e1ca
@@ -18,6 +18,7 @@ __all__ = ['ConfFixture']
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
|
|
||||||
def _import_opts(conf, module, opts, group=None):
|
def _import_opts(conf, module, opts, group=None):
|
||||||
@@ -70,6 +71,24 @@ class ConfFixture(fixtures.Fixture):
|
|||||||
'_notifier_opts',
|
'_notifier_opts',
|
||||||
'oslo_messaging_notifications')
|
'oslo_messaging_notifications')
|
||||||
|
|
||||||
|
# Support older test cases that still use the set_override
|
||||||
|
# with the old config key names
|
||||||
|
def decorator_for_set_override(wrapped_function):
|
||||||
|
@wraps(wrapped_function)
|
||||||
|
def _wrapper(*args, **kwargs):
|
||||||
|
group = 'oslo_messaging_notifications'
|
||||||
|
if args[0] == 'notification_driver':
|
||||||
|
args = ('driver', args[1], group)
|
||||||
|
elif args[0] == 'notification_transport_url':
|
||||||
|
args = ('transport_url', args[1], group)
|
||||||
|
elif args[0] == 'notification_topics':
|
||||||
|
args = ('topics', args[1], group)
|
||||||
|
return wrapped_function(*args, **kwargs)
|
||||||
|
return _wrapper
|
||||||
|
|
||||||
|
self.conf.set_override = decorator_for_set_override(
|
||||||
|
self.conf.set_override)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ConfFixture, self).setUp()
|
super(ConfFixture, self).setUp()
|
||||||
self.addCleanup(self.conf.reset)
|
self.addCleanup(self.conf.reset)
|
||||||
|
|||||||
33
oslo_messaging/tests/test_fixture.py
Normal file
33
oslo_messaging/tests/test_fixture.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright 2015 Mirantis Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_messaging.tests import utils as test_utils
|
||||||
|
|
||||||
|
|
||||||
|
class TestConfFixture(test_utils.BaseTestCase):
|
||||||
|
def test_old_notifications_config_override(self):
|
||||||
|
conf = self.messaging_conf.conf
|
||||||
|
conf.set_override(
|
||||||
|
"notification_driver", "messaging")
|
||||||
|
conf.set_override(
|
||||||
|
"notification_transport_url", "http://xyz")
|
||||||
|
conf.set_override(
|
||||||
|
"notification_topics", ['topic1'])
|
||||||
|
|
||||||
|
self.assertEqual("messaging",
|
||||||
|
conf.oslo_messaging_notifications.driver)
|
||||||
|
self.assertEqual("http://xyz",
|
||||||
|
conf.oslo_messaging_notifications.transport_url)
|
||||||
|
self.assertEqual(['topic1'],
|
||||||
|
conf.oslo_messaging_notifications.topics)
|
||||||
Reference in New Issue
Block a user