diff options
author | Mark McLoughlin <markmc@redhat.com> | 2014-06-16 07:05:15 +0100 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2014-06-16 07:05:15 +0100 |
commit | 25b887767bcf7b63380b682759344575bcf9e4d3 (patch) | |
tree | eafe22d0cb7253e97958346fa310eb0fe8d987f1 | |
parent | 1746fd2908bec7dd215d06667c615174237809cc (diff) | |
download | oslo-config-25b887767bcf7b63380b682759344575bcf9e4d3.tar.gz |
Add more tests for positional CLI opts
Add tests to ensure that e.g. default=None, default=[], etc. works
as expected.
Change-Id: I66f5df6e622a66faa1d00ee0846cbec5eb119283
-rw-r--r-- | tests/test_cfg.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/test_cfg.py b/tests/test_cfg.py index d979215..457c264 100644 --- a/tests/test_cfg.py +++ b/tests/test_cfg.py @@ -511,24 +511,39 @@ class PositionalTestCase(BaseTestCase): self.assertTrue(hasattr(self.conf, 'foo')) self.assertEqual(self.conf.foo, value) - def test_positional_str_default(self): + def test_positional_str_none_default(self): self._do_pos_test(cfg.StrOpt, None, [], None) + def test_positional_str_default(self): + self._do_pos_test(cfg.StrOpt, 'bar', [], 'bar') + def test_positional_str_arg(self): self._do_pos_test(cfg.StrOpt, None, ['bar'], 'bar') + def test_positional_int_none_default(self): + self._do_pos_test(cfg.IntOpt, None, [], None) + def test_positional_int_default(self): self._do_pos_test(cfg.IntOpt, 10, [], 10) def test_positional_int_arg(self): self._do_pos_test(cfg.IntOpt, None, ['20'], 20) + def test_positional_float_none_default(self): + self._do_pos_test(cfg.FloatOpt, None, [], None) + def test_positional_float_default(self): self._do_pos_test(cfg.FloatOpt, 1.0, [], 1.0) def test_positional_float_arg(self): self._do_pos_test(cfg.FloatOpt, None, ['2.0'], 2.0) + def test_positional_list_none_default(self): + self._do_pos_test(cfg.ListOpt, None, [], None) + + def test_positional_list_empty_default(self): + self._do_pos_test(cfg.ListOpt, [], [], []) + def test_positional_list_default(self): self._do_pos_test(cfg.ListOpt, ['bar'], [], ['bar']) @@ -536,6 +551,12 @@ class PositionalTestCase(BaseTestCase): self._do_pos_test(cfg.ListOpt, None, ['blaa,bar'], ['blaa', 'bar']) + def test_positional_dict_none_default(self): + self._do_pos_test(cfg.DictOpt, None, [], None) + + def test_positional_dict_empty_default(self): + self._do_pos_test(cfg.DictOpt, {}, [], {}) + def test_positional_dict_default(self): self._do_pos_test(cfg.DictOpt, {'key1': 'bar'}, [], {'key1': 'bar'}) @@ -544,6 +565,12 @@ class PositionalTestCase(BaseTestCase): ['key1:blaa,key2:bar'], {'key1': 'blaa', 'key2': 'bar'}) + def test_positional_multistr_none_default(self): + self._do_pos_test(cfg.MultiStrOpt, None, [], None) + + def test_positional_multistr_empty_default(self): + self._do_pos_test(cfg.MultiStrOpt, [], [], []) + def test_positional_multistr_default(self): self._do_pos_test(cfg.MultiStrOpt, ['bar'], [], ['bar']) |