Fix displaying column headers for OSC list commands

Add consistency to displaying column headers for the following
list commands:
openstack share type list
openstack share type access list
openstack share access list

Partial-Bug: #1945170
Change-Id: I88b3103696ab2f47b11d6d938193788e69b5a739
This commit is contained in:
Leslie Stevens 2021-10-01 19:42:10 +00:00
parent be8326b7cc
commit 1e8330468f
6 changed files with 26 additions and 22 deletions

View File

@ -202,19 +202,19 @@ class ListShareAccess(command.Lister):
access_list = share.access_list()
list_of_keys = [
'id',
'access_type',
'access_to',
'access_level',
'state'
'ID',
'Access Type',
'Access To',
'Access Level',
'State'
]
if share_client.api_version >= api_versions.APIVersion("2.21"):
list_of_keys.append('access_key')
list_of_keys.append('Access Key')
if share_client.api_version >= api_versions.APIVersion("2.33"):
list_of_keys.append('created_at')
list_of_keys.append('updated_at')
list_of_keys.append('Created At')
list_of_keys.append('Updated At')
values = (oscutils.get_item_properties(
a, list_of_keys) for a in access_list)

View File

@ -81,7 +81,7 @@ class ListShareTypeAccess(command.Lister):
data = share_client.share_type_access.list(share_type)
columns = ['Project_ID']
columns = ['Project ID']
values = (oscutils.get_item_properties(s, columns) for s in data)
return (columns, values)

View File

@ -420,7 +420,9 @@ class ListShareType(command.Lister):
values = (oscutils.get_dict_properties(
s._info, ATTRIBUTES) for s in formatted_types)
return (ATTRIBUTES, values)
columns = utils.format_column_headers(ATTRIBUTES)
return (columns, values)
class ShowShareType(command.ShowOne):

View File

@ -170,14 +170,14 @@ class TestShareAccessDelete(TestShareAccess):
class TestShareAccessList(TestShareAccess):
access_rules_columns = [
'id',
'access_type',
'access_to',
'access_level',
'state',
'access_key',
'created_at',
'updated_at'
'ID',
'Access Type',
'Access To',
'Access Level',
'State',
'Access Key',
'Created At',
'Updated At'
]
def setUp(self):

View File

@ -19,6 +19,7 @@ from osc_lib import utils as oscutils
from manilaclient import api_versions
from manilaclient.common.apiclient.exceptions import BadRequest
from manilaclient.common.apiclient.exceptions import NotFound
from manilaclient.osc import utils
from manilaclient.osc.v2 import share_types as osc_share_types
from manilaclient.tests.unit.osc import osc_utils
from manilaclient.tests.unit.osc.v2 import fakes as manila_fakes
@ -448,6 +449,7 @@ class TestShareTypeUnset(TestShareType):
class TestShareTypeList(TestShareType):
share_types = manila_fakes.FakeShareType.create_share_types()
columns = utils.format_column_headers(COLUMNS)
def setUp(self):
super(TestShareTypeList, self).setUp()
@ -473,7 +475,7 @@ class TestShareTypeList(TestShareType):
search_opts={},
show_all=False
)
self.assertEqual(COLUMNS, columns)
self.assertEqual(self.columns, columns)
self.assertEqual(list(self.values), list(data))
def test_share_type_list_all(self):
@ -490,7 +492,7 @@ class TestShareTypeList(TestShareType):
self.shares_mock.list.assert_called_once_with(
search_opts={},
show_all=True)
self.assertEqual(COLUMNS, columns)
self.assertEqual(self.columns, columns)
self.assertEqual(list(self.values), list(data))
def test_share_type_list_extra_specs(self):
@ -507,7 +509,7 @@ class TestShareTypeList(TestShareType):
self.shares_mock.list.assert_called_once_with(
search_opts={'extra_specs': {'snapshot_support': 'True'}},
show_all=False)
self.assertEqual(COLUMNS, columns)
self.assertEqual(self.columns, columns)
self.assertEqual(list(self.values), list(data))
def test_share_type_list_api_versions_exception(self):

View File

@ -91,7 +91,7 @@ class TestShareTypeAccessAllow(TestShareTypeAccess):
class TestShareTypeAccessList(TestShareTypeAccess):
columns = ['Project_ID']
columns = ['Project ID']
data = (('',), ('',))
def setUp(self):