def verify_xml(self, incoming_xml, respond_obj, file=False):
"""
Verify the incoming_xml data with either
a. whole xml file
b. tag text pairs
:param:
incoming_xml: an xml string
respond_obj: contains the verification detail from datafile
file: indicate if comparing whole file or just pairs
:return:
True if whole file match/all pairs match
False if not match
"""
if file:
status = False
for expect_xml_file in respond_obj["request_verify_data"]:
expect_xml_file = getAbsPath(expect_xml_file, getDirName(self.datafile))
status, _, _, _ = compare_xml(incoming_xml, expect_xml_file,
output_file=False, sorted_json=False, remove_namespaces=True)
return status
else:
incoming_xml = ET.fromstring(incoming_xml, parser=ET.XMLParser(encoding="utf-8"))
for element_pair in respond_obj["request_verify"]:
xpath = element_pair.split(",")[0][4:]
value = element_pair.split(",")[1][6:]
incoming_value = getChildElementWithSpecificXpath(incoming_xml, xpath)
if incoming_value is None or value != incoming_value.text:
return False
return True
rest_server_class.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录