當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。