Fix functional readonly_cli tests
Parser.listing method return empty list if env doesn't have resources, so assertTableStruct works wrong, doesn't check field names in the output table. This change add new assert(assertTableHeaders) to check resource attributes. Change-Id: Ieca67b5cc2202467527c5a2dfbd7b2f2b4d5ad8d Closes-Bug: #1458932
This commit is contained in:
@@ -41,6 +41,17 @@ class ClientTestBase(base.ClientTestBase):
|
||||
return self.clients.cinder(*args,
|
||||
**kwargs)
|
||||
|
||||
def assertTableHeaders(self, output_lines, field_names):
|
||||
"""Verify that output table has headers item listed in field_names.
|
||||
|
||||
:param output_lines: output table from cmd
|
||||
:param field_names: field names from the output table of the cmd
|
||||
"""
|
||||
table = self.parser.table(output_lines)
|
||||
headers = table['headers']
|
||||
for field in field_names:
|
||||
self.assertIn(field, headers)
|
||||
|
||||
def assertTableStruct(self, items, field_names):
|
||||
"""Verify that all items has keys listed in field_names.
|
||||
|
||||
|
@@ -28,22 +28,22 @@ class CinderClientReadOnlyTests(base.ClientTestBase):
|
||||
|
||||
# Commands in order listed in 'cinder help'
|
||||
def test_absolute_limits(self):
|
||||
limits = self.parser.listing(self.cinder('absolute-limits'))
|
||||
self.assertTableStruct(limits, ['Name', 'Value'])
|
||||
limits = self.cinder('absolute-limits')
|
||||
self.assertTableHeaders(limits, ['Name', 'Value'])
|
||||
|
||||
def test_availability_zones(self):
|
||||
zone_list = self.parser.listing(self.cinder('availability-zone-list'))
|
||||
self.assertTableStruct(zone_list, ['Name', 'Status'])
|
||||
zone_list = self.cinder('availability-zone-list')
|
||||
self.assertTableHeaders(zone_list, ['Name', 'Status'])
|
||||
|
||||
def test_backup_list(self):
|
||||
backup_list = self.parser.listing(self.cinder('backup-list'))
|
||||
self.assertTableStruct(backup_list, ['ID', 'Volume ID', 'Status',
|
||||
backup_list = self.cinder('backup-list')
|
||||
self.assertTableHeaders(backup_list, ['ID', 'Volume ID', 'Status',
|
||||
'Name', 'Size', 'Object Count',
|
||||
'Container'])
|
||||
|
||||
def test_encryption_type_list(self):
|
||||
encrypt_list = self.parser.listing(self.cinder('encryption-type-list'))
|
||||
self.assertTableStruct(encrypt_list, ['Volume Type ID', 'Provider',
|
||||
encrypt_list = self.cinder('encryption-type-list')
|
||||
self.assertTableHeaders(encrypt_list, ['Volume Type ID', 'Provider',
|
||||
'Cipher', 'Key Size',
|
||||
'Control Location'])
|
||||
|
||||
@@ -56,34 +56,34 @@ class CinderClientReadOnlyTests(base.ClientTestBase):
|
||||
self.assertEqual('Value', headers[1])
|
||||
|
||||
def test_list(self):
|
||||
list = self.parser.listing(self.cinder('list'))
|
||||
self.assertTableStruct(list, ['ID', 'Status', 'Name', 'Size',
|
||||
list = self.cinder('list')
|
||||
self.assertTableHeaders(list, ['ID', 'Status', 'Name', 'Size',
|
||||
'Volume Type', 'Bootable',
|
||||
'Attached to'])
|
||||
|
||||
def test_qos_list(self):
|
||||
qos_list = self.parser.listing(self.cinder('qos-list'))
|
||||
self.assertTableStruct(qos_list, ['ID', 'Name', 'Consumer', 'specs'])
|
||||
qos_list = self.cinder('qos-list')
|
||||
self.assertTableHeaders(qos_list, ['ID', 'Name', 'Consumer', 'specs'])
|
||||
|
||||
def test_rate_limits(self):
|
||||
rate_limits = self.parser.listing(self.cinder('rate-limits'))
|
||||
self.assertTableStruct(rate_limits, ['Verb', 'URI', 'Value', 'Remain',
|
||||
rate_limits = self.cinder('rate-limits')
|
||||
self.assertTableHeaders(rate_limits, ['Verb', 'URI', 'Value', 'Remain',
|
||||
'Unit', 'Next_Available'])
|
||||
|
||||
def test_service_list(self):
|
||||
service_list = self.parser.listing(self.cinder('service-list'))
|
||||
self.assertTableStruct(service_list, ['Binary', 'Host', 'Zone',
|
||||
service_list = self.cinder('service-list')
|
||||
self.assertTableHeaders(service_list, ['Binary', 'Host', 'Zone',
|
||||
'Status', 'State', 'Updated_at'])
|
||||
|
||||
def test_snapshot_list(self):
|
||||
snapshot_list = self.parser.listing(self.cinder('snapshot-list'))
|
||||
self.assertTableStruct(snapshot_list, ['ID', 'Volume ID', 'Status',
|
||||
snapshot_list = self.cinder('snapshot-list')
|
||||
self.assertTableHeaders(snapshot_list, ['ID', 'Volume ID', 'Status',
|
||||
'Name', 'Size'])
|
||||
|
||||
def test_transfer_list(self):
|
||||
transfer_list = self.parser.listing(self.cinder('transfer-list'))
|
||||
self.assertTableStruct(transfer_list, ['ID', 'Volume ID', 'Name'])
|
||||
transfer_list = self.cinder('transfer-list')
|
||||
self.assertTableHeaders(transfer_list, ['ID', 'Volume ID', 'Name'])
|
||||
|
||||
def test_type_list(self):
|
||||
type_list = self.parser.listing(self.cinder('type-list'))
|
||||
self.assertTableStruct(type_list, ['ID', 'Name'])
|
||||
type_list = self.cinder('type-list')
|
||||
self.assertTableHeaders(type_list, ['ID', 'Name'])
|
||||
|
Reference in New Issue
Block a user