Increase UT Coverage

UT Coverage for following is increased:
- magnumclient/tests/v1/test_certificates_shell.py
- magnumclient/tests/test_utils.py

Change-Id: If15aaf9206599126dde14d237bb56b52222ea0cf
Partially-Implements: blueprint magnumclient-ut-coverage
This commit is contained in:
yatin 2017-01-23 17:08:36 +05:30
parent 1e87068dd3
commit 806e660654
2 changed files with 21 additions and 0 deletions

View File

@ -108,6 +108,14 @@ class ArgsArrayToPatchTest(test_utils.BaseTestCase):
self.assertEqual([{'op': 'remove', 'path': '/foo'},
{'op': 'remove', 'path': '/extra/bar'}], patch)
def test_args_array_to_patch_invalid_op(self):
my_args = {
'attributes': ['/foo', 'extra/bar'],
'op': 'invalid',
}
self.assertRaises(exc.CommandError, utils.args_array_to_patch,
my_args['op'], my_args['attributes'])
class FormatLabelsTest(test_utils.BaseTestCase):

View File

@ -14,6 +14,7 @@
import mock
from magnumclient.common import cliutils as utils
from magnumclient.tests.v1 import shell_test_base
from magnumclient.v1 import certificates_shell
@ -129,3 +130,15 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
mock_isfile.assert_called_once_with('path/csr.pem')
mock_file.assert_not_called()
mock_cert_create.assert_not_called()
@mock.patch('magnumclient.v1.clusters.ClusterManager.get')
@mock.patch('magnumclient.v1.certificates.CertificateManager.get')
def test_ca_show_failure_with_invalid_field(self, mock_cert_get,
mock_cluster_get):
_error_msg = [".*?^--cluster or --bay"]
self.assertRaises(utils.MissingArgs,
self._test_arg_failure,
'ca-show',
_error_msg)
mock_cert_get.assert_not_called()
mock_cluster_get.assert_not_called()