change assert_show_fields to not fail on new fields
whenever a resource adds a field (which is allowed in our API guidelines), OSC functional tests fail, because we validate the resource keys to a hardcoded list. instead, this change proposes that the logic of assert_show_fields is flipped around, so our hardcoded list acts as a minimum set of values that must appear in the resource. as part of this change, some fields were remove from the constants since they were not actually in the returned data. also, delete unused code `assert_show_structure`. Change-Id: I8c0f0e80ea472f9c7f93c5f1f0ae52048e6cd7da
This commit is contained in:
parent
b69b539a42
commit
42ac82b1a4
@ -16,7 +16,6 @@ import shlex
|
|||||||
import subprocess
|
import subprocess
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
import six
|
|
||||||
from tempest.lib.cli import output_parser
|
from tempest.lib.cli import output_parser
|
||||||
from tempest.lib import exceptions
|
from tempest.lib import exceptions
|
||||||
|
|
||||||
@ -88,23 +87,17 @@ class TestCase(testtools.TestCase):
|
|||||||
for field in field_names:
|
for field in field_names:
|
||||||
self.assertIn(field, item)
|
self.assertIn(field, item)
|
||||||
|
|
||||||
def assert_show_fields(self, items, field_names):
|
def assert_show_fields(self, show_output, field_names):
|
||||||
"""Verify that all items have keys listed in field_names."""
|
"""Verify that all items have keys listed in field_names."""
|
||||||
for item in items:
|
|
||||||
for key in six.iterkeys(item):
|
|
||||||
self.assertIn(key, field_names)
|
|
||||||
|
|
||||||
def assert_show_structure(self, items, field_names):
|
# field_names = ['name', 'description']
|
||||||
"""Verify that all field_names listed in keys of all items."""
|
# show_output = [{'name': 'fc2b98d8faed4126b9e371eda045ade2'},
|
||||||
if isinstance(items, list):
|
# {'description': 'description-821397086'}]
|
||||||
o = {}
|
# this next line creates a flattened list of all 'keys' (like 'name',
|
||||||
for d in items:
|
# and 'description' out of the output
|
||||||
o.update(d)
|
all_headers = [item for sublist in show_output for item in sublist]
|
||||||
else:
|
for field_name in field_names:
|
||||||
o = items
|
self.assertIn(field_name, all_headers)
|
||||||
item_keys = o.keys()
|
|
||||||
for field in field_names:
|
|
||||||
self.assertIn(field, item_keys)
|
|
||||||
|
|
||||||
def parse_show_as_object(self, raw_output):
|
def parse_show_as_object(self, raw_output):
|
||||||
"""Return a dict with values parsed from cli output."""
|
"""Return a dict with values parsed from cli output."""
|
||||||
|
@ -22,14 +22,13 @@ BASIC_LIST_HEADERS = ['ID', 'Name']
|
|||||||
class IdentityTests(base.TestCase):
|
class IdentityTests(base.TestCase):
|
||||||
"""Functional tests for Identity commands. """
|
"""Functional tests for Identity commands. """
|
||||||
|
|
||||||
USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id',
|
USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id', 'username']
|
||||||
'username', 'domain_id', 'default_project_id']
|
PROJECT_FIELDS = ['enabled', 'id', 'name', 'description']
|
||||||
PROJECT_FIELDS = ['enabled', 'id', 'name', 'description', 'domain_id']
|
|
||||||
TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
|
TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
|
||||||
ROLE_FIELDS = ['id', 'name', 'links', 'domain_id']
|
ROLE_FIELDS = ['id', 'name', 'domain_id']
|
||||||
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
|
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
|
||||||
ENDPOINT_FIELDS = ['id', 'region', 'service_id', 'service_name',
|
ENDPOINT_FIELDS = ['id', 'region', 'service_id', 'service_name',
|
||||||
'service_type', 'enabled', 'publicurl',
|
'service_type', 'publicurl',
|
||||||
'adminurl', 'internalurl']
|
'adminurl', 'internalurl']
|
||||||
|
|
||||||
EC2_CREDENTIALS_FIELDS = ['access', 'project_id', 'secret',
|
EC2_CREDENTIALS_FIELDS = ['access', 'project_id', 'secret',
|
||||||
|
@ -23,15 +23,15 @@ BASIC_LIST_HEADERS = ['ID', 'Name']
|
|||||||
class IdentityTests(base.TestCase):
|
class IdentityTests(base.TestCase):
|
||||||
"""Functional tests for Identity commands. """
|
"""Functional tests for Identity commands. """
|
||||||
|
|
||||||
DOMAIN_FIELDS = ['description', 'enabled', 'id', 'name', 'links']
|
DOMAIN_FIELDS = ['description', 'enabled', 'id', 'name']
|
||||||
GROUP_FIELDS = ['description', 'domain_id', 'id', 'name', 'links']
|
GROUP_FIELDS = ['description', 'domain_id', 'id', 'name']
|
||||||
TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
|
TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
|
||||||
USER_FIELDS = ['email', 'enabled', 'id', 'name', 'name',
|
USER_FIELDS = ['email', 'enabled', 'id', 'name', 'name',
|
||||||
'domain_id', 'default_project_id', 'description',
|
'domain_id', 'default_project_id', 'description',
|
||||||
'password_expires_at']
|
'password_expires_at']
|
||||||
PROJECT_FIELDS = ['description', 'id', 'domain_id', 'is_domain',
|
PROJECT_FIELDS = ['description', 'id', 'domain_id', 'is_domain',
|
||||||
'enabled', 'name', 'parent_id', 'links']
|
'enabled', 'name', 'parent_id']
|
||||||
ROLE_FIELDS = ['id', 'name', 'links', 'domain_id']
|
ROLE_FIELDS = ['id', 'name', 'domain_id']
|
||||||
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
|
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
|
||||||
REGION_FIELDS = ['description', 'enabled', 'parent_region', 'region']
|
REGION_FIELDS = ['description', 'enabled', 'parent_region', 'region']
|
||||||
ENDPOINT_FIELDS = ['id', 'region', 'region_id', 'service_id',
|
ENDPOINT_FIELDS = ['id', 'region', 'region_id', 'service_id',
|
||||||
|
Loading…
Reference in New Issue
Block a user