当前位置: 首页>>代码示例>>Python>>正文


Python FormProcessorInterface.get_attachment方法代码示例

本文整理汇总了Python中corehq.form_processor.interfaces.FormProcessorInterface.get_attachment方法的典型用法代码示例。如果您正苦于以下问题:Python FormProcessorInterface.get_attachment方法的具体用法?Python FormProcessorInterface.get_attachment怎么用?Python FormProcessorInterface.get_attachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.form_processor.interfaces.FormProcessorInterface的用法示例。


在下文中一共展示了FormProcessorInterface.get_attachment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_basic_edit

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import get_attachment [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)
开发者ID:johan--,项目名称:commcare-hq,代码行数:42,代码来源:test_edits.py


注:本文中的corehq.form_processor.interfaces.FormProcessorInterface.get_attachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。