diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-12-04 18:43:07 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-12-04 18:43:08 +0000 |
commit | 04b86f7021abcba5f325e117b84dca4ae226f78a (patch) | |
tree | d36393c0f41154345ddd953df3d7c9e555ff80f0 /tests/test_cfg.py | |
parent | 125711997eb3d9fd6894463b1c8513181e215e7c (diff) | |
parent | e447675ef8a24665bfe3e5c22389f1c73b79923f (diff) | |
download | oslo-config-04b86f7021abcba5f325e117b84dca4ae226f78a.tar.gz |
Merge "Fix wrong order of positional args in cli"
Diffstat (limited to 'tests/test_cfg.py')
-rw-r--r-- | tests/test_cfg.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_cfg.py b/tests/test_cfg.py index 423f42d..c9c25c9 100644 --- a/tests/test_cfg.py +++ b/tests/test_cfg.py @@ -622,6 +622,62 @@ class PositionalTestCase(BaseTestCase): cfg.StrOpt('foo', required=True, positional=True)) self.assertRaises(cfg.RequiredOptError, self.conf, []) + def test_positional_opts_order(self): + self.conf.register_cli_opts(( + cfg.StrOpt('command', positional=True), + cfg.StrOpt('arg1', positional=True), + cfg.StrOpt('arg2', positional=True)) + ) + + self.conf(['command', 'arg1', 'arg2']) + + self.assertEqual('command', self.conf.command) + self.assertEqual('arg1', self.conf.arg1) + self.assertEqual('arg2', self.conf.arg2) + + def test_positional_opt_order(self): + self.conf.register_cli_opt( + cfg.StrOpt('command', positional=True)) + self.conf.register_cli_opt( + cfg.StrOpt('arg1', positional=True)) + self.conf.register_cli_opt( + cfg.StrOpt('arg2', positional=True)) + + self.conf(['command', 'arg1', 'arg2']) + + self.assertEqual('command', self.conf.command) + self.assertEqual('arg1', self.conf.arg1) + self.assertEqual('arg2', self.conf.arg2) + + def test_positional_opt_unregister(self): + command = cfg.StrOpt('command', positional=True) + arg1 = cfg.StrOpt('arg1', positional=True) + arg2 = cfg.StrOpt('arg2', positional=True) + self.conf.register_cli_opt(command) + self.conf.register_cli_opt(arg1) + self.conf.register_cli_opt(arg2) + + self.conf(['command', 'arg1', 'arg2']) + + self.assertEqual('command', self.conf.command) + self.assertEqual('arg1', self.conf.arg1) + self.assertEqual('arg2', self.conf.arg2) + + self.conf.reset() + + self.conf.unregister_opt(arg1) + self.conf.unregister_opt(arg2) + + arg0 = cfg.StrOpt('arg0', positional=True) + self.conf.register_cli_opt(arg0) + self.conf.register_cli_opt(arg1) + + self.conf(['command', 'arg0', 'arg1']) + + self.assertEqual('command', self.conf.command) + self.assertEqual('arg0', self.conf.arg0) + self.assertEqual('arg1', self.conf.arg1) + class ConfigFileOptsTestCase(BaseTestCase): |