From 1e8330468f6b3f2d24de09874e41ad8c85ad520f Mon Sep 17 00:00:00 2001 From: Leslie Stevens Date: Fri, 1 Oct 2021 19:42:10 +0000 Subject: [PATCH] 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 --- manilaclient/osc/v2/share_access_rules.py | 16 ++++++++-------- manilaclient/osc/v2/share_type_access.py | 2 +- manilaclient/osc/v2/share_types.py | 4 +++- .../tests/unit/osc/v2/test_share_access_rules.py | 16 ++++++++-------- .../tests/unit/osc/v2/test_share_type.py | 8 +++++--- .../tests/unit/osc/v2/test_share_type_access.py | 2 +- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/manilaclient/osc/v2/share_access_rules.py b/manilaclient/osc/v2/share_access_rules.py index c0b4158de..9a02c7d2a 100644 --- a/manilaclient/osc/v2/share_access_rules.py +++ b/manilaclient/osc/v2/share_access_rules.py @@ -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) diff --git a/manilaclient/osc/v2/share_type_access.py b/manilaclient/osc/v2/share_type_access.py index 2a2547adb..6682c32ce 100644 --- a/manilaclient/osc/v2/share_type_access.py +++ b/manilaclient/osc/v2/share_type_access.py @@ -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) diff --git a/manilaclient/osc/v2/share_types.py b/manilaclient/osc/v2/share_types.py index 6e04a0456..145aded6b 100644 --- a/manilaclient/osc/v2/share_types.py +++ b/manilaclient/osc/v2/share_types.py @@ -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): diff --git a/manilaclient/tests/unit/osc/v2/test_share_access_rules.py b/manilaclient/tests/unit/osc/v2/test_share_access_rules.py index 9bc7e4edd..fee205f1c 100644 --- a/manilaclient/tests/unit/osc/v2/test_share_access_rules.py +++ b/manilaclient/tests/unit/osc/v2/test_share_access_rules.py @@ -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): diff --git a/manilaclient/tests/unit/osc/v2/test_share_type.py b/manilaclient/tests/unit/osc/v2/test_share_type.py index b943d9d4a..3de8267e4 100644 --- a/manilaclient/tests/unit/osc/v2/test_share_type.py +++ b/manilaclient/tests/unit/osc/v2/test_share_type.py @@ -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): diff --git a/manilaclient/tests/unit/osc/v2/test_share_type_access.py b/manilaclient/tests/unit/osc/v2/test_share_type_access.py index 54846a844..00a7a2bab 100644 --- a/manilaclient/tests/unit/osc/v2/test_share_type_access.py +++ b/manilaclient/tests/unit/osc/v2/test_share_type_access.py @@ -91,7 +91,7 @@ class TestShareTypeAccessAllow(TestShareTypeAccess): class TestShareTypeAccessList(TestShareTypeAccess): - columns = ['Project_ID'] + columns = ['Project ID'] data = (('',), ('',)) def setUp(self):