本文整理汇总了Python中corehq.form_processor.interfaces.FormProcessorInterface.update_properties方法的典型用法代码示例。如果您正苦于以下问题:Python FormProcessorInterface.update_properties方法的具体用法?Python FormProcessorInterface.update_properties怎么用?Python FormProcessorInterface.update_properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.form_processor.interfaces.FormProcessorInterface
的用法示例。
在下文中一共展示了FormProcessorInterface.update_properties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic_edit
# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import update_properties [as 别名]
def test_basic_edit(self):
xml_data1, xml_data2 = self._get_files()
yesterday = datetime.utcnow() - timedelta(days=1)
xform = FormProcessorInterface.post_xform(xml_data1)
self.assertEqual(self.ID, xform.id)
self.assertEqual("XFormInstance", xform.doc_type)
self.assertEqual("", xform.form['vitals']['height'])
self.assertEqual("other", xform.form['assessment']['categories'])
# post form back in time to simulate an edit
FormProcessorInterface.update_properties(
xform,
domain=self.domain,
received_on=yesterday,
)
xform = FormProcessorInterface.post_xform(xml_data2, domain=self.domain)
self.assertEqual(self.ID, xform.id)
self.assertEqual("XFormInstance", xform.doc_type)
self.assertEqual("100", xform.form['vitals']['height'])
self.assertEqual("Edited Baby!", xform.form['assessment']['categories'])
[deprecated_xform] = FormProcessorInterface.get_by_doc_type(self.domain, 'XFormDeprecated')
self.assertEqual(self.ID, deprecated_xform.orig_id)
self.assertNotEqual(self.ID, deprecated_xform.id)
self.assertEqual('XFormDeprecated', deprecated_xform.doc_type)
self.assertEqual("", deprecated_xform.form['vitals']['height'])
self.assertEqual("other", deprecated_xform.form['assessment']['categories'])
self.assertEqual(xform.received_on, deprecated_xform.received_on)
self.assertEqual(xform.deprecated_form_id, deprecated_xform.id)
self.assertTrue(xform.edited_on > deprecated_xform.received_on)
self.assertEqual(
FormProcessorInterface.get_attachment(deprecated_xform.id, 'form.xml'),
xml_data1
)
self.assertEqual(FormProcessorInterface.get_attachment(self.ID, 'form.xml'), xml_data2)