Merge "Bugfix: Use fields option for cluster template list"

This commit is contained in:
Zuul 2020-03-31 09:39:49 +00:00 committed by Gerrit Code Review
commit 18f5928215
2 changed files with 7 additions and 3 deletions

View File

@ -354,6 +354,8 @@ class ListTemplateCluster(command.Lister):
mag_client = self.app.client_manager.container_infra
columns = ['uuid', 'name']
if parsed_args.fields:
columns += parsed_args.fields.split(',')
cts = mag_client.cluster_templates.list(limit=parsed_args.limit,
sort_key=parsed_args.sort_key,
sort_dir=parsed_args.sort_dir)

View File

@ -271,22 +271,24 @@ class TestClusterTemplateList(TestClusterTemplate):
'--limit', '1',
'--sort-key', 'key',
'--sort-dir', 'asc',
'--fields', 'fields'
'--fields', 'field1,field2'
]
verifylist = [
('limit', 1),
('sort_key', 'key'),
('sort_dir', 'asc'),
('fields', 'fields'),
('fields', 'field1,field2'),
]
verifycolumns = self.columns + ['field1', 'field2']
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
columns, data = self.cmd.take_action(parsed_args)
self.cluster_templates_mock.list.assert_called_with(
limit=1,
sort_dir='asc',
sort_key='key',
)
self.assertEqual(verifycolumns, columns)
def test_cluster_template_list_bad_sort_dir_fail(self):
arglist = [