summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2015-12-01 17:23:20 -0500
committerOleksii Zamiatin <ozamiatin@mirantis.com>2015-12-02 14:05:02 +0000
commitb6ad95e1caa19a755e11077facaa2022b64d0cf0 (patch)
tree82ea522d9b5372b30c6bdeac68003df39dc32608
parentba42571b5a92f08a5a5d09a8b2cf077189db7567 (diff)
downloadoslo-messaging-b6ad95e1caa19a755e11077facaa2022b64d0cf0.tar.gz
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
-rw-r--r--oslo_messaging/conffixture.py19
-rw-r--r--oslo_messaging/tests/test_fixture.py33
2 files changed, 52 insertions, 0 deletions
diff --git a/oslo_messaging/conffixture.py b/oslo_messaging/conffixture.py
index 2f53d3f..42e9d51 100644
--- a/oslo_messaging/conffixture.py
+++ b/oslo_messaging/conffixture.py
@@ -18,6 +18,7 @@ __all__ = ['ConfFixture']
import sys
import fixtures
+from functools import wraps
def _import_opts(conf, module, opts, group=None):
@@ -70,6 +71,24 @@ class ConfFixture(fixtures.Fixture):
'_notifier_opts',
'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):
super(ConfFixture, self).setUp()
self.addCleanup(self.conf.reset)
diff --git a/oslo_messaging/tests/test_fixture.py b/oslo_messaging/tests/test_fixture.py
new file mode 100644
index 0000000..dfa78b6
--- /dev/null
+++ b/oslo_messaging/tests/test_fixture.py
@@ -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)