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


Python FormProcessorInterface.post_case_blocks方法代码示例

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


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

示例1: CaseBugTest

# 需要导入模块: from corehq.form_processor.interfaces.processor import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.processor.FormProcessorInterface import post_case_blocks [as 别名]

#.........这里部分代码省略.........
        """
        xml_data = self.get_xml('empty_id')
        response, form, cases = self.interface.submit_form_locally(xml_data)
        self.assertIn('IllegalCaseId', response.content)

    def _testCornerCaseDatatypeBugs(self, value):

        def _test(custom_format_args):
            case_id = uuid.uuid4().hex
            format_args = {
                'case_id': case_id,
                'form_id': uuid.uuid4().hex,
                'user_id': uuid.uuid4().hex,
                'case_name': 'data corner cases',
                'case_type': 'datatype-check',
            }
            format_args.update(custom_format_args)
            for filename in ['bugs_in_case_create_datatypes', 'bugs_in_case_update_datatypes']:
                xml_data = self.get_xml(filename).format(**format_args)
                response, form, [case] = self.interface.submit_form_locally(xml_data)

                self.assertEqual(format_args['user_id'], case.user_id)
                self.assertEqual(format_args['case_name'], case.name)
                self.assertEqual(format_args['case_type'], case.type)

        _test({'case_name': value})
        _test({'case_type': value})
        _test({'user_id': value})

    def testDateInCasePropertyBug(self):
        """
        Submits a case name/case type/user_id that looks like a date
        """
        self._testCornerCaseDatatypeBugs('2011-11-16')

    def testIntegerInCasePropertyBug(self):
        """
        Submits a case name/case type/user_id that looks like a number
        """
        self._testCornerCaseDatatypeBugs('42')

    def testDecimalInCasePropertyBug(self):
        """
        Submits a case name/case type/user_id that looks like a decimal
        """
        self._testCornerCaseDatatypeBugs('4.06')

    def testDuplicateCasePropertiesBug(self):
        """
        Submit multiple values for the same property in an update block
        """
        xml_data = self.get_xml('duplicate_case_properties')
        response, form, [case] = self.interface.submit_form_locally(xml_data)
        self.assertEqual("", case.foo)

        xml_data = self.get_xml('duplicate_case_properties_2')
        response, form, [case] = self.interface.submit_form_locally(xml_data)
        self.assertEqual("2", case.bar)

    def testMultipleCaseBlocks(self):
        """
        How do we do when submitting a form with multiple blocks for the same case?
        """
        xml_data = self.get_xml('multiple_case_blocks')
        response, form, [case] = self.interface.submit_form_locally(xml_data)

        self.assertEqual('1630005', case.community_code)
        self.assertEqual('SantaMariaCahabon', case.district_name)
        self.assertEqual('TAMERLO', case.community_name)

        ids = case.xform_ids
        self.assertEqual(1, len(ids))
        self.assertEqual(form.form_id, ids[0])

    def testLotsOfSubcases(self):
        """
        How do we do when submitting a form with multiple blocks for the same case?
        """
        xml_data = self.get_xml('lots_of_subcases')
        response, form, cases = self.interface.submit_form_locally(xml_data)
        self.assertEqual(11, len(cases))

    def testSubmitToDeletedCase(self):
        # submitting to a deleted case should succeed and affect the case
        case_id = 'immagetdeleted'
        [xform, [case]] = self.interface.post_case_blocks([
            CaseBlock(create=True, case_id=case_id, user_id='whatever',
                update={'foo': 'bar'}).as_xml()
        ])
        case.soft_delete()

        self.assertEqual('bar', case.foo)
        self.assertTrue(case.is_deleted)

        [xform, [case]] = self.interface.post_case_blocks([
            CaseBlock(create=False, case_id=case_id, user_id='whatever',
                      update={'foo': 'not_bar'}).as_xml()
        ])
        self.assertEqual('not_bar', case.foo)
        self.assertTrue(case.is_deleted)
开发者ID:nnestle,项目名称:commcare-hq,代码行数:104,代码来源:test_bugs.py


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