diff --git a/magnumclient/tests/v1/shell_test_base.py b/magnumclient/tests/v1/shell_test_base.py index ad29ae8f..8adacc9e 100644 --- a/magnumclient/tests/v1/shell_test_base.py +++ b/magnumclient/tests/v1/shell_test_base.py @@ -42,7 +42,13 @@ class TestCommandLineArgument(utils.TestCase): _few_argument_error = [ '.*?^usage: magnum ', '.*?^error: (the following arguments|too few arguments)', - ".*?^Try" + ".*?^Try 'magnum help ", + ] + + _invalid_value_error = [ + '.*?^usage: ', + '.*?^error: argument .*: invalid .* value:', + ".*?^Try 'magnum help ", ] def setUp(self): diff --git a/magnumclient/tests/v1/test_bays_shell.py b/magnumclient/tests/v1/test_bays_shell.py index de3c6d60..a6afffe6 100644 --- a/magnumclient/tests/v1/test_bays_shell.py +++ b/magnumclient/tests/v1/test_bays_shell.py @@ -73,6 +73,12 @@ class ShellTest(shell_test_base.TestCommandLineArgument): self._mandatory_arg_error) self.assertFalse(mock_create.called) + @mock.patch('magnumclient.v1.bays.BayManager.create') + def test_bay_create_failure_invalid_node_count(self, mock_create): + self._test_arg_failure('bay-create --baymodel xxx --node-count test', + self._invalid_value_error) + self.assertFalse(mock_create.called) + @mock.patch('magnumclient.v1.bays.BayManager.create') def test_bay_create_failure_only_bay_create_timeout(self, mock_create): self._test_arg_failure('bay-create --timeout 15', diff --git a/magnumclient/v1/bays_shell.py b/magnumclient/v1/bays_shell.py index 43facc9d..4c9a88f3 100644 --- a/magnumclient/v1/bays_shell.py +++ b/magnumclient/v1/bays_shell.py @@ -38,6 +38,8 @@ def do_bay_list(cs, args): help='ID or name of the baymodel.') @utils.arg('--node-count', metavar='', + type=int, + default=1, help='The bay node count.') @utils.arg('--master-count', metavar='',