tests: Fix API extension check

The check for extensions was not using a machine readable format for
output. This meant an API check could match on a substring, e.g. a check
for 'qos' would match on 'qos-specs'. Address this issue by switching
our command invocation to use JSON output and migrating the check
function from the general base class to the networking base class.

Change-Id: Idc6dc54503031ddf3e148f50ed53ad8898f7a7e3
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-11-10 10:20:03 +00:00
parent 7dbe6e6d3d
commit c251cb89a5

View File

@ -119,9 +119,13 @@ class TestCase(testtools.TestCase):
return bool(ret)
@classmethod
def is_extension_enabled(cls, alias):
def is_extension_enabled(cls, alias, *, service='network'):
"""Ask client cloud if extension is enabled"""
return alias in cls.openstack('extension list -f value -c Alias')
extensions = cls.openstack(
f'extension list --{service}',
parse_output=True,
)
return alias in [x['Alias'] for x in extensions]
@classmethod
def get_openstack_configuration_value(cls, configuration):