diff --git a/nova/tests/functional/api_samples/README.rst b/nova/tests/functional/api_samples/README.rst index a08cac3a4292..42c4041edefe 100644 --- a/nova/tests/functional/api_samples/README.rst +++ b/nova/tests/functional/api_samples/README.rst @@ -23,7 +23,6 @@ ensures that it's in sync. Debugging sample generation --------------------------- -If a .tpl is changed, its matching .xml and .json must be removed -else the samples won't be generated. If an entirely new extension is -added, a directory for it must be created before its samples will -be generated. +If a .tpl is changed, its matching .json must be removed else the samples +won't be generated. If an entirely new extension is added, a directory for +it must be created before its samples will be generated. diff --git a/nova/tests/functional/api_samples_test_base.py b/nova/tests/functional/api_samples_test_base.py index 2c33eba05307..dcf5cc2d110a 100644 --- a/nova/tests/functional/api_samples_test_base.py +++ b/nova/tests/functional/api_samples_test_base.py @@ -16,7 +16,6 @@ import os import re -from lxml import etree from oslo.serialization import jsonutils from oslo.utils import importutils import six @@ -36,40 +35,16 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): extension_name = None def _pretty_data(self, data): - if self.ctype == 'json': - data = jsonutils.dumps(jsonutils.loads(data), sort_keys=True, - indent=4) - - else: - if data is None: - # Likely from missing XML file. - return "" - xml = etree.XML(data) - data = etree.tostring(xml, encoding="UTF-8", - xml_declaration=True, pretty_print=True) + data = jsonutils.dumps(jsonutils.loads(data), sort_keys=True, + indent=4) return '\n'.join(line.rstrip() for line in data.split('\n')).strip() def _objectify(self, data): if not data: return {} - if self.ctype == 'json': - # NOTE(vish): allow non-quoted replacements to survive json - data = re.sub(r'([^"])%\((.+)\)s([^"])', r'\1"%(int:\2)s"\3', data) - return jsonutils.loads(data) - else: - def to_dict(node): - ret = {} - if node.items(): - ret.update(dict(node.items())) - if node.text: - ret['__content__'] = node.text - if node.tag: - ret['__tag__'] = node.tag - for element in node: - ret.setdefault(node.tag, []) - ret[node.tag].append(to_dict(element)) - return ret - return to_dict(etree.fromstring(data)) + # NOTE(vish): allow non-quoted replacements to survive json + data = re.sub(r'([^"])%\((.+)\)s([^"])', r'\1"%(int:\2)s"\3', data) + return jsonutils.loads(data) @classmethod def _get_sample_path(cls, name, dirname, suffix=''):