本文整理匯總了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)