Merge "Return the `port` column headers expected in the list command"

This commit is contained in:
Zuul 2025-04-01 10:48:10 +00:00 committed by Gerrit Code Review
commit cf25526e94
2 changed files with 14 additions and 7 deletions
openstackclient
network/v2
tests/functional/network/v2

@ -943,15 +943,12 @@ class ListPort(command.Lister):
for item in columns
]
headers, attrs = utils.calculate_header_and_attrs(
column_headers, columns, parsed_args
)
return (
headers,
column_headers,
(
utils.get_item_properties(
s,
attrs,
columns,
formatters=_list_formatters,
)
for s in data

@ -12,6 +12,8 @@
import uuid
from tempest.lib import exceptions as tempest_exc
from openstackclient.tests.functional.network.v2 import common
@ -162,8 +164,16 @@ class PortTests(common.NetworkTagTests):
id_list = [p['ID'] for p in json_output]
self.assertIn(id1, id_list)
self.assertIn(id2, id_list)
# Check an unknown field exists
self.assertIn('device_id', json_output[0])
# Check an unknown field does not exist
self.assertNotIn('device_id', json_output[0])
# Test list with only unknown fields
exc = self.assertRaises(
tempest_exc.CommandFailed,
self.openstack,
'port list -c device_id',
)
self.assertIn("No recognized column names in ['device_id']", str(exc))
def test_port_set(self):
"""Test create, set, show, delete"""