Merge "Relax requirement of region-id for hosts and cells"

This commit is contained in:
Jenkins 2017-03-01 15:19:47 +00:00 committed by Gerrit Code Review
commit c558ab65cf
4 changed files with 28 additions and 4 deletions

View File

@ -32,7 +32,6 @@ def do_cell_show(cc, args):
@cliutils.arg('-r', '--region',
metavar='<region>',
type=int,
required=True,
help='ID of the region that the cell belongs to.')
@cliutils.arg('--cloud',
metavar='<cloud>',
@ -110,8 +109,10 @@ def do_cell_list(cc, args):
)
)
params['sort_key'] = sort_key
if args.region is not None:
params['region_id'] = args.region
params['sort_dir'] = args.sort_dir
params['region_id'] = args.region
params['marker'] = args.marker
params['autopaginate'] = args.all

View File

@ -32,7 +32,6 @@ def do_host_show(cc, args):
@cliutils.arg('-r', '--region',
metavar='<region>',
type=int,
required=True,
help='ID of the region that the host belongs to.')
@cliutils.arg('--cloud',
metavar='<cloud>',
@ -140,8 +139,10 @@ def do_host_list(cc, args):
)
)
params['sort_key'] = sort_key
if args.region is not None:
params['region_id'] = args.region
params['sort_dir'] = args.sort_dir
params['region_id'] = args.region
params['marker'] = args.marker
params['autopaginate'] = args.all

View File

@ -163,6 +163,17 @@ class TestCellsShell(base.ShellTestCase):
marker=None,
)
@mock.patch('cratonclient.v1.cells.CellManager.list')
def test_cell_list_does_not_require_region_id(self, cell_list):
"""Verify -r/--region are not required to list cells."""
self.shell('cell-list --limit 10')
cell_list.assert_called_once_with(
sort_dir='asc',
autopaginate=False,
limit=10,
marker=None,
)
def test_cell_list_sort_dir_invalid_value(self):
"""Verify --sort-dir with invalid args, fails with Command Error."""
(_, error) = self.shell(

View File

@ -93,6 +93,17 @@ class TestHostsShell(base.ShellTestCase):
autopaginate=False,
)
@mock.patch('cratonclient.v1.hosts.HostManager.list')
def test_host_list_does_not_require_region(self, host_list):
"""Verify -r/--region is not required to list hosts."""
self.shell('host-list --limit 10')
host_list.assert_called_once_with(
limit=10,
sort_dir='asc',
marker=None,
autopaginate=False,
)
def test_host_list_limit_negative_num_failure(self):
"""Verify --limit X, where X is a negative integer, fails.