Demonstrate that MultiStr values from multiple sources are merged

Add a test to show that when we encounter the same MultiStrOption in
several sources, the values are merged into one list.

Related-Bug: #1490990
Change-Id: Ie0324572191f084a3646d8bfb1d214d14221244d
This commit is contained in:
Doug Hellmann 2015-09-03 15:52:08 +00:00 committed by Davanum Srinivas (dims)
parent 7a9f4e7d67
commit b270375dd8

View File

@ -2302,6 +2302,30 @@ class ConfigDirTestCase(BaseTestCase):
self.assertTrue(hasattr(self.conf.snafu, 'bell'))
self.assertEqual(self.conf.snafu.bell, 'whistle-02')
def test_config_dir_multistr(self):
# Demonstrate that values for multistr options found in
# different sources are combined.
self.conf.register_cli_opt(cfg.MultiStrOpt('foo'))
dir = tempfile.mkdtemp()
self.tempdirs.append(dir)
paths = self.create_tempfiles([(os.path.join(dir, '00-test'),
'[DEFAULT]\n'
'foo = bar-00\n'),
(os.path.join(dir, '02-test'),
'[DEFAULT]\n'
'foo = bar-02\n'),
(os.path.join(dir, '01-test'),
'[DEFAULT]\n'
'foo = bar-01\n')])
self.conf(['--foo', 'bar',
'--config-dir', os.path.dirname(paths[0])])
self.assertTrue(hasattr(self.conf, 'foo'))
self.assertEqual(['bar', 'bar-00', 'bar-01', 'bar-02'], self.conf.foo)
def test_config_dir_file_precedence(self):
snafu_group = cfg.OptGroup('snafu')
self.conf.register_group(snafu_group)