diff options
author | Mark McLoughlin <markmc@redhat.com> | 2012-01-12 06:55:25 +0000 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2012-01-12 06:55:25 +0000 |
commit | d567e9a31392aace25216b3f02f95552b8d43472 (patch) | |
tree | 8d0ab93673ce6af35f94e46a385f44f8a8ec443c /tests | |
parent | 64f3da8df984fe3e8ef437897f4899bfa0a9dd8c (diff) | |
download | oslo-d567e9a31392aace25216b3f02f95552b8d43472.tar.gz oslo-d567e9a31392aace25216b3f02f95552b8d43472.tar.xz oslo-d567e9a31392aace25216b3f02f95552b8d43472.zip |
Add cfg test case for exceptions' __str__ methods
Increases coverage from 93% to 97%
Change-Id: I6a41b31e29238831fe2a888d5d64dc0bffd770c0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_cfg.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index 7152496..c2cf310 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -25,6 +25,45 @@ import stubout from openstack.common.cfg import * +class ExceptionsTestCase(unittest.TestCase): + + def test_error(self): + msg = str(Error('foobar')) + self.assertEquals(msg, 'foobar') + + def test_args_already_parsed_error(self): + msg = str(ArgsAlreadyParsedError('foobar')) + self.assertEquals(msg, 'arguments already parsed: foobar') + + def test_no_such_opt_error(self): + msg = str(NoSuchOptError('foo')) + self.assertEquals(msg, 'no such option: foo') + + def test_no_such_opt_error_with_group(self): + msg = str(NoSuchOptError('foo', OptGroup('bar'))) + self.assertEquals(msg, 'no such option in group bar: foo') + + def test_no_such_group_error(self): + msg = str(NoSuchGroupError('bar')) + self.assertEquals(msg, 'no such group: bar') + + def test_duplicate_opt_error(self): + msg = str(DuplicateOptError('foo')) + self.assertEquals(msg, 'duplicate option: foo') + + def test_template_substitution_error(self): + msg = str(TemplateSubstitutionError('foobar')) + self.assertEquals(msg, 'template substitution error: foobar') + + def test_config_files_not_found_error(self): + msg = str(ConfigFilesNotFoundError(['foo', 'bar'])) + self.assertEquals(msg, 'Failed to read some config files: foo,bar') + + def test_config_file_parse_error(self): + msg = str(ConfigFileParseError('foo', 'foobar')) + self.assertEquals(msg, 'Failed to parse foo: foobar') + + class BaseTestCase(unittest.TestCase): def setUp(self): |