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 <shardy@redhat.com>
This commit is contained in:
@@ -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):
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user