From: Steven Hardy Date: Wed, 12 Sep 2012 11:07:51 +0000 (+0100) Subject: heat tests : functional test utils add response_xml_item X-Git-Tag: 2014.1~1422 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ec0f4efd32b66a883680c707e5c0c32f82f7d847;p=openstack-build%2Fheat-build.git heat tests : functional test utils add response_xml_item Add response_xml_item method to Stack, which allows stack API XML responses to be more easily parsed base on xpath prefix and keyname Change-Id: I96437bd7ff4575e9262d46c4c21f4408041e147d Signed-off-by: Steven Hardy --- diff --git a/heat/tests/functional/util.py b/heat/tests/functional/util.py index b296ff10..ac44423b 100644 --- a/heat/tests/functional/util.py +++ b/heat/tests/functional/util.py @@ -437,6 +437,19 @@ class Stack(object): value = output.findtext('OutputValue') return value + def response_xml_item(self, response, prefix, key): + ''' + Extract response item via xpath prefix and key name + we expect the prefix to map to a single Element item + ''' + root = etree.fromstring(response) + output_list = root.xpath(prefix) + assert output_list + assert len(output_list) == 1 + output = output_list.pop() + value = output.findtext(key) + return value + class StackBoto(Stack): '''