Merge "Fix UT for duplicate name args test case"

This commit is contained in:
Jenkins 2017-03-17 11:36:59 +00:00 committed by Gerrit Code Review
commit a8c6579151
2 changed files with 12 additions and 2 deletions

View File

@ -51,6 +51,12 @@ class TestCommandLineArgument(utils.TestCase):
".*?^Try 'magnum help ",
]
_duplicate_name_arg_error = [
'.*?^usage: ',
'.*?^error: (Duplicate "<name>" arguments:)',
".*?^Try 'magnum help ",
]
_deprecated_warning = [
'.*(WARNING: The \-\-[a-z\-]* parameter is deprecated)+',
('.*(Use the [\<\-a-z\-\>]* (positional )*parameter to avoid seeing '

View File

@ -14,6 +14,7 @@
import mock
from magnumclient.common import cliutils
from magnumclient import exceptions
from magnumclient.tests.v1 import shell_test_base
from magnumclient.tests.v1 import test_clustertemplates_shell
@ -305,8 +306,11 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
@mock.patch('magnumclient.v1.clusters.ClusterManager.create')
def test_cluster_create_failure_duplicate_name(self, mock_create):
self._test_arg_failure('cluster-create foo --name bar',
self._mandatory_arg_error)
self.assertRaises(cliutils.DuplicateArgs,
self._test_arg_failure,
'cluster-create foo --name bar '
'--cluster-template xxx',
self._duplicate_name_arg_error)
mock_create.assert_not_called()
@mock.patch('magnumclient.v1.clusters.ClusterManager.delete')