Fix UT for duplicate name args test case

The test is intended for testing duplicate name arg but
test raised mandatory_args error due to absense of
--cluster-template arg, so test is now updated to raise
DuplicateArgs Exception.
Introduced in: https://review.openstack.org/#/c/434411/

Change-Id: Ieee8bfebfb2c0d03d953550e545bccbdee42e688
Implements: blueprint positional-name
This commit is contained in:
yatinkarel 2017-03-06 13:13:24 +05:30
parent 7937f06a64
commit 3ac3169201
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')