From c251cb89a5cd11120106f6b0fb662b7daf815597 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 10 Nov 2023 10:20:03 +0000 Subject: [PATCH] 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 --- openstackclient/tests/functional/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openstackclient/tests/functional/base.py b/openstackclient/tests/functional/base.py index 9b4235bec6..86fca8fe83 100644 --- a/openstackclient/tests/functional/base.py +++ b/openstackclient/tests/functional/base.py @@ -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):