diff options
| author | Ilya Tyaptin <ityaptin@mirantis.com> | 2015-04-29 14:30:25 +0300 |
|---|---|---|
| committer | Juan Antonio Osorio Robles <juan.osorio.robles@ericsson.com> | 2015-05-11 10:59:35 +0300 |
| commit | ba02fdc1df58eb530b0d86bfa3daed8af23aff59 (patch) | |
| tree | ce264e5eab0057ffa8240c05503cbfe0228cbd17 /ceilometerclient/tests/unit/test_shell.py | |
| parent | fe20f3c29ea84bf7a9a5fb96f92d01c65d8c9e5f (diff) | |
| download | python-ceilometerclient-ba02fdc1df58eb530b0d86bfa3daed8af23aff59.tar.gz | |
[unittest] Increase client and shell modules cover
Add tests to increase unittest coverage of ceilometerclient.client,
ceilometerclient.shell, ceilometerclient.v2.shell.
Change-Id: I83a64ee31d6068a5903ef85ec85d5780828a24d7
Diffstat (limited to 'ceilometerclient/tests/unit/test_shell.py')
| -rw-r--r-- | ceilometerclient/tests/unit/test_shell.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/ceilometerclient/tests/unit/test_shell.py b/ceilometerclient/tests/unit/test_shell.py index 6dd1157..4f8dd4f 100644 --- a/ceilometerclient/tests/unit/test_shell.py +++ b/ceilometerclient/tests/unit/test_shell.py @@ -39,15 +39,6 @@ FAKE_V3_ENV = {'OS_USERNAME': 'username', class ShellTestBase(utils.BaseTestCase): - # Patch os.environ to avoid required auth info. - def make_env(self, env_version, exclude=None): - env = dict((k, v) for k, v in env_version.items() if k != exclude) - self.useFixture(fixtures.MonkeyPatch('os.environ', env)) - - -class ShellHelpTest(ShellTestBase): - RE_OPTIONS = re.DOTALL | re.MULTILINE - @mock.patch('sys.stdout', new=six.StringIO()) @mock.patch.object(ks_session, 'Session', mock.MagicMock()) @mock.patch.object(v2client.client.HTTPClient, @@ -62,6 +53,15 @@ class ShellHelpTest(ShellTestBase): return sys.stdout.getvalue() + # Patch os.environ to avoid required auth info. + def make_env(self, env_version, exclude=None): + env = dict((k, v) for k, v in env_version.items() if k != exclude) + self.useFixture(fixtures.MonkeyPatch('os.environ', env)) + + +class ShellHelpTest(ShellTestBase): + RE_OPTIONS = re.DOTALL | re.MULTILINE + def test_help_unknown_command(self): self.assertRaises(exc.CommandError, self.shell, 'help foofoo') @@ -98,6 +98,18 @@ class ShellHelpTest(ShellTestBase): self.assertEqual(600, parser.get_default('timeout')) +class ShellBashCompletionTest(ShellTestBase): + + def test_bash_completion(self): + completion_commands = self.shell("bash-completion") + options = completion_commands.split(' ') + self.assertNotIn('bash-completion', options) + self.assertNotIn('bash_completion', options) + for option in options: + self.assertThat(option, + matchers.MatchesRegex(r'[a-z0-9-]')) + + class ShellKeystoneV2Test(ShellTestBase): @mock.patch.object(ks_session, 'Session') @@ -177,7 +189,7 @@ class ShellTimeoutTest(ShellTestBase): self._test_timeout('0', expected_msg) @mock.patch.object(ks_session, 'Session') - def test_timeout_kesytone_session(self, mocked_session): + def test_timeout_keystone_session(self, mocked_session): mocked_session.side_effect = exc.HTTPUnauthorized("FAIL") self.make_env(FAKE_V2_ENV) args = ['--debug', '--timeout', '5', 'alarm-list'] |
