From ec0f4efd32b66a883680c707e5c0c32f82f7d847 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 12 Sep 2012 12:07:51 +0100 Subject: [PATCH] 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 --- heat/tests/functional/util.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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): ''' -- 2.45.2