Browse Source

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
Ben Nemec 8 months ago
parent
commit
98c0d2c1db
1 changed files with 12 additions and 1 deletions
  1. 12
    1
      oslo_reports/tests/test_openstack_generators.py

+ 12
- 1
oslo_reports/tests/test_openstack_generators.py View File

@@ -94,6 +94,16 @@ class TestOpenstackGenerators(base.BaseTestCase):
94 94
         model = os_cgen.ConfigReportGenerator(conf)()
95 95
         model.set_current_view_type('text')
96 96
 
97
+        # oslo.config added a default config_source opt which gets included
98
+        # in our output, but we also need to support older versions where that
99
+        # wasn't the case.  This logic can be removed once the oslo.config
100
+        # lower constraint becomes >=6.4.0.
101
+        config_source_line = '  config_source = \n'
102
+        try:
103
+            conf.config_source
104
+        except cfg.NoSuchOptError:
105
+            config_source_line = ''
106
+
97 107
         target_str = ('\ncheese: \n'
98 108
                       '  from_cow = True\n'
99 109
                       '  group_secrets = ***\n'
@@ -101,8 +111,9 @@ class TestOpenstackGenerators(base.BaseTestCase):
101 111
                       '  sharpness = 1\n'
102 112
                       '\n'
103 113
                       'default: \n'
114
+                      '%s'
104 115
                       '  crackers = triscuit\n'
105
-                      '  secrets = ***')
116
+                      '  secrets = ***') % config_source_line
106 117
         self.assertEqual(target_str, six.text_type(model))
107 118
 
108 119
     def test_package_report_generator(self):

Loading…
Cancel
Save