From 98c0d2c1db7bbcb30b5bfe4f347bdb2124de25a5 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Wed, 1 Aug 2018 21:44:32 +0000 Subject: [PATCH] Update unit test to reflect latest oslo.config Because we added the default config_source opt in oslo.config, it is now showing up in the GMR output and needs to be included in the expected content. However, for lower constraints testing we also need to continue to support the older versions without config_source, so the target_str is built dynamically based on whether the opt exists. Change-Id: I20b01285000ce84b69e8bd3cee8078edf03616f8 --- oslo_reports/tests/test_openstack_generators.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/oslo_reports/tests/test_openstack_generators.py b/oslo_reports/tests/test_openstack_generators.py index f5b1cda..b2ddab8 100644 --- a/oslo_reports/tests/test_openstack_generators.py +++ b/oslo_reports/tests/test_openstack_generators.py @@ -94,6 +94,16 @@ class TestOpenstackGenerators(base.BaseTestCase): model = os_cgen.ConfigReportGenerator(conf)() model.set_current_view_type('text') + # oslo.config added a default config_source opt which gets included + # in our output, but we also need to support older versions where that + # wasn't the case. This logic can be removed once the oslo.config + # lower constraint becomes >=6.4.0. + config_source_line = ' config_source = \n' + try: + conf.config_source + except cfg.NoSuchOptError: + config_source_line = '' + target_str = ('\ncheese: \n' ' from_cow = True\n' ' group_secrets = ***\n' @@ -101,8 +111,9 @@ class TestOpenstackGenerators(base.BaseTestCase): ' sharpness = 1\n' '\n' 'default: \n' + '%s' ' crackers = triscuit\n' - ' secrets = ***') + ' secrets = ***') % config_source_line self.assertEqual(target_str, six.text_type(model)) def test_package_report_generator(self):