summaryrefslogtreecommitdiff
path: root/tests/test_cfg.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-09-12 12:30:29 +0000
committerGerrit Code Review <review@openstack.org>2014-09-12 12:30:29 +0000
commit059579ac2189b94bc9e9555b2e9acfb31a83ef53 (patch)
tree63c1f2fdca0511d37ca5404581629c3f306d00d0 /tests/test_cfg.py
parent4d89f038186e393a9da3afe4ae45a98a250e052e (diff)
parenta50ea6f2827bedf95188442cfb50d2348cbb3194 (diff)
downloadoslo-config-059579ac2189b94bc9e9555b2e9acfb31a83ef53.tar.gz
Merge "Looks for variable subtitution in the same group"1.4.0.0a51.4.0
Diffstat (limited to 'tests/test_cfg.py')
-rw-r--r--tests/test_cfg.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_cfg.py b/tests/test_cfg.py
index 7b6d282..dab7542 100644
--- a/tests/test_cfg.py
+++ b/tests/test_cfg.py
@@ -2101,8 +2101,55 @@ class TemplateSubstitutionTestCase(BaseTestCase):
self.assertTrue(hasattr(self.conf, 'ba'))
self.assertTrue(hasattr(self.conf.ba, 'r'))
+ self.assertEqual(self.conf.foo, '123')
self.assertEqual(self.conf.ba.r, 123)
+ def test_sub_group_from_default_deprecated(self):
+ self.conf.register_group(cfg.OptGroup('ba'))
+ self.conf.register_cli_opt(cfg.StrOpt(
+ 'foo', default='123', deprecated_group='DEFAULT'), group='ba')
+ self.conf.register_cli_opt(cfg.IntOpt('r', default='$foo'), group='ba')
+
+ self.conf([])
+
+ self.assertTrue(hasattr(self.conf, 'ba'))
+ self.assertTrue(hasattr(self.conf.ba, 'foo'))
+ self.assertEqual(self.conf.ba.foo, '123')
+ self.assertTrue(hasattr(self.conf.ba, 'r'))
+ self.assertEqual(self.conf.ba.r, 123)
+
+ def test_sub_group_from_args_deprecated(self):
+ self.conf.register_group(cfg.OptGroup('ba'))
+ self.conf.register_cli_opt(cfg.StrOpt(
+ 'foo', default='123', deprecated_group='DEFAULT'), group='ba')
+ self.conf.register_cli_opt(cfg.IntOpt('r', default='$foo'), group='ba')
+
+ self.conf(['--ba-foo=4242'])
+
+ self.assertTrue(hasattr(self.conf, 'ba'))
+ self.assertTrue(hasattr(self.conf.ba, 'foo'))
+ self.assertTrue(hasattr(self.conf.ba, 'r'))
+ self.assertEqual(self.conf.ba.foo, '4242')
+ self.assertEqual(self.conf.ba.r, 4242)
+
+ def test_sub_group_from_configfile_deprecated(self):
+ self.conf.register_group(cfg.OptGroup('ba'))
+ self.conf.register_cli_opt(cfg.StrOpt(
+ 'foo', default='123', deprecated_group='DEFAULT'), group='ba')
+ self.conf.register_cli_opt(cfg.IntOpt('r', default='$foo'), group='ba')
+
+ paths = self.create_tempfiles([('test',
+ '[DEFAULT]\n'
+ 'foo=4242\n')])
+
+ self.conf(['--config-file', paths[0]])
+
+ self.assertTrue(hasattr(self.conf, 'ba'))
+ self.assertTrue(hasattr(self.conf.ba, 'foo'))
+ self.assertTrue(hasattr(self.conf.ba, 'r'))
+ self.assertEqual(self.conf.ba.foo, '4242')
+ self.assertEqual(self.conf.ba.r, 4242)
+
class ConfigDirTestCase(BaseTestCase):