本文整理汇总了Python中corehq.form_processor.interfaces.FormProcessorInterface.get_xml_element方法的典型用法代码示例。如果您正苦于以下问题:Python FormProcessorInterface.get_xml_element方法的具体用法?Python FormProcessorInterface.get_xml_element怎么用?Python FormProcessorInterface.get_xml_element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.form_processor.interfaces.FormProcessorInterface
的用法示例。
在下文中一共展示了FormProcessorInterface.get_xml_element方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_various_encodings
# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import get_xml_element [as 别名]
def test_various_encodings(self):
tests = (
('utf-8', u'हिन्दी चट्टानों'),
('UTF-8', u'हिन्दी चट्टानों'),
('ASCII', 'hello'),
)
file_path = os.path.join(os.path.dirname(__file__), "data", "encoding.xml")
with open(file_path, "rb") as f:
xml_template = f.read()
for encoding, value in tests:
xml_data = xml_template.format(
encoding=encoding,
form_id=uuid.uuid4().hex,
sample_value=value.encode(encoding),
)
xform = FormProcessorInterface.post_xform(xml_data)
self.assertEqual(value, xform.form['test'])
elem = FormProcessorInterface.get_xml_element(xform)
self.assertEqual(value, elem.find('{http://commcarehq.org/couchforms-tests}test').text)