diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-10 16:55:46 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-10 16:55:46 +0000 |
| commit | c9db396cb6473246e5ccf3072ba592ef47fd9d16 (patch) | |
| tree | 382f7498ae70b05707776ef616300b3a9105da69 /tests/unit | |
| parent | f6cf448b92dc1df1c1d922e03a6f44770460b9fe (diff) | |
| parent | 038d59778eecf953375da701b4cd55d4e3ca309f (diff) | |
| download | oslo-c9db396cb6473246e5ccf3072ba592ef47fd9d16.tar.gz oslo-c9db396cb6473246e5ccf3072ba592ef47fd9d16.tar.xz oslo-c9db396cb6473246e5ccf3072ba592ef47fd9d16.zip | |
Merge "Add import_opt() method to ConfigOpts"
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/test_cfg.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index d6286d3..14a85c9 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -1111,6 +1111,32 @@ class UnregisterOptTestCase(BaseTestCase): self.assertFalse(hasattr(self.conf.blaa, 'foo')) +class ImportOptTestCase(BaseTestCase): + + def test_import_opt(self): + self.assertFalse(hasattr(CONF, 'blaa')) + CONF.import_opt('blaa', 'tests.testmods.blaa_opt') + self.assertTrue(hasattr(CONF, 'blaa')) + + def test_import_opt_in_group(self): + self.assertFalse(hasattr(CONF, 'bar')) + CONF.import_opt('foo', 'tests.testmods.bar_foo_opt', group='bar') + self.assertTrue(hasattr(CONF, 'bar')) + self.assertTrue(hasattr(CONF.bar, 'foo')) + + def test_import_opt_import_errror(self): + self.assertRaises(ImportError, CONF.import_opt, + 'blaa', 'tests.testmods.blaablaa_opt') + + def test_import_opt_no_such_opt(self): + self.assertRaises(NoSuchOptError, CONF.import_opt, + 'blaablaa', 'tests.testmods.blaa_opt') + + def test_import_opt_no_such_group(self): + self.assertRaises(NoSuchGroupError, CONF.import_opt, + 'blaa', 'tests.testmods.blaa_opt', group='blaa') + + class RequiredOptsTestCase(BaseTestCase): def setUp(self): |
