summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/base.py
diff options
context:
space:
mode:
authorSteve Martinelli <s.martinelli@gmail.com>2017-01-24 00:10:51 -0500
committerSteve Martinelli <s.martinelli@gmail.com>2017-01-25 13:09:16 -0800
commit42ac82b1a4970da688ea8fe6c1eb35c87bae8652 (patch)
treee431bc9a7336f561849395c28f5fb723226d858c /openstackclient/tests/functional/base.py
parentb69b539a422860bfb402093ff9d93a1b6e338b26 (diff)
downloadpython-openstackclient-42ac82b1a4970da688ea8fe6c1eb35c87bae8652.tar.gz
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
Diffstat (limited to 'openstackclient/tests/functional/base.py')
-rw-r--r--openstackclient/tests/functional/base.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/openstackclient/tests/functional/base.py b/openstackclient/tests/functional/base.py
index fb78ea62..85743296 100644
--- a/openstackclient/tests/functional/base.py
+++ b/openstackclient/tests/functional/base.py
@@ -16,7 +16,6 @@ import shlex
import subprocess
import testtools
-import six
from tempest.lib.cli import output_parser
from tempest.lib import exceptions
@@ -88,23 +87,17 @@ class TestCase(testtools.TestCase):
for field in field_names:
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."""
- for item in items:
- for key in six.iterkeys(item):
- self.assertIn(key, field_names)
-
- def assert_show_structure(self, items, field_names):
- """Verify that all field_names listed in keys of all items."""
- if isinstance(items, list):
- o = {}
- for d in items:
- o.update(d)
- else:
- o = items
- item_keys = o.keys()
- for field in field_names:
- self.assertIn(field, item_keys)
+
+ # field_names = ['name', 'description']
+ # show_output = [{'name': 'fc2b98d8faed4126b9e371eda045ade2'},
+ # {'description': 'description-821397086'}]
+ # this next line creates a flattened list of all 'keys' (like 'name',
+ # and 'description' out of the output
+ all_headers = [item for sublist in show_output for item in sublist]
+ for field_name in field_names:
+ self.assertIn(field_name, all_headers)
def parse_show_as_object(self, raw_output):
"""Return a dict with values parsed from cli output."""