Require int value for --limit option
Currently the value passed to the --limit option is not validated as part of argument parser and results in an ugly error. $ openstack stack list --limit a invalid literal for int() with base 10: 'a' $ This enables the validation in argument parser to require integer, which shows more clear error. $ openstack stack list --limit a openstack stack list: error: argument --limit: invalid int value: 'a' $ Change-Id: I17397bc202a08de63b715fa15d0f33754393c226
This commit is contained in:
@@ -80,6 +80,7 @@ class ListConfig(command.Lister):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--limit',
|
'--limit',
|
||||||
metavar='<limit>',
|
metavar='<limit>',
|
||||||
|
type=int,
|
||||||
help=_('Limit the number of configs returned')
|
help=_('Limit the number of configs returned')
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@@ -537,6 +537,7 @@ class ListStack(command.Lister):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--limit',
|
'--limit',
|
||||||
metavar='<limit>',
|
metavar='<limit>',
|
||||||
|
type=int,
|
||||||
help=_('The number of stacks returned')
|
help=_('The number of stacks returned')
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@@ -83,7 +83,7 @@ class TestListConfig(TestConfig):
|
|||||||
arglist = ['--limit', '3']
|
arglist = ['--limit', '3']
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, [])
|
parsed_args = self.check_parser(self.cmd, arglist, [])
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.mock_client.software_configs.list.assert_called_with(limit='3')
|
self.mock_client.software_configs.list.assert_called_with(limit=3)
|
||||||
|
|
||||||
def test_config_list_marker(self):
|
def test_config_list_marker(self):
|
||||||
arglist = ['--marker', 'id123']
|
arglist = ['--marker', 'id123']
|
||||||
|
Reference in New Issue
Block a user