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


Python FormProcessorInterface.submit_form_locally方法代码示例

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


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

示例1: testUserRestoreWithCase

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    def testUserRestoreWithCase(self):
        file_path = os.path.join(os.path.dirname(__file__), "data", "create_short.xml")
        with open(file_path, "rb") as f:
            xml_data = f.read()
        FormProcessorInterface.submit_form_locally(xml_data, self.domain)

        expected_case_block = """
        <case case_id="asdf" date_modified="2010-06-29T13:42:50.000000Z" user_id="foo"
            xmlns="http://commcarehq.org/case/transaction/v2">
            <create>
                <case_type>test_case_type</case_type>
                <case_name>test case name</case_name>
                <owner_id>foo</owner_id>
            </create>
            <update>
                <external_id>someexternal</external_id>
            </update>
        </case>"""

        restore_payload = generate_restore_payload(
            project=Domain(name=self.domain),
            user=dummy_user(),
            items=True,
            version=V3
        )
        sync_log_id = SyncLog.view(
            "phone/sync_logs_by_user",
            include_docs=True,
            reduce=False,
        ).one().get_id
        check_xml_line_by_line(
            self,
            dummy_restore_xml(sync_log_id, expected_case_block, items=4),
            restore_payload
        )
开发者ID:johan--,项目名称:commcare-hq,代码行数:37,代码来源:test_ota_restore_v3.py

示例2: test_conflicting_ids

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
 def test_conflicting_ids(self):
     """
     If a form and a case share an ID it's a conflict
     """
     xml_data = self.get_xml('id_conflicts')
     with self.assertRaises(BulkSaveError):
         FormProcessorInterface.submit_form_locally(xml_data)
开发者ID:johan--,项目名称:commcare-hq,代码行数:9,代码来源:test_bugs.py

示例3: test_cant_own_case

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    def test_cant_own_case(self):
        _, _, [case] = FormProcessorInterface.submit_form_locally(ALICE_XML, ALICE_DOMAIN)
        response, form, cases = FormProcessorInterface.submit_form_locally(EVE_XML, EVE_DOMAIN)

        self.assertIn('IllegalCaseId', response.content)
        self.assertFalse(hasattr(FormProcessorInterface.get_case(case.id), 'plan_to_buy_gun'))

        FormProcessorInterface.submit_form_locally(ALICE_UPDATE_XML, ALICE_DOMAIN)
        self.assertEqual(FormProcessorInterface.get_case(case.id).plan_to_buy_gun, 'no')
开发者ID:johan--,项目名称:commcare-hq,代码行数:11,代码来源:test_domains.py

示例4: testTopLevelExclusion

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    def testTopLevelExclusion(self):
        """
        Entire forms tagged as device logs should be excluded
        """
        file_path = os.path.join(os.path.dirname(__file__), "data", "exclusion", "device_report.xml")
        with open(file_path, "rb") as f:
            xml_data = f.read()

        FormProcessorInterface.submit_form_locally(xml_data)
        self.assertEqual(0, get_total_case_count())
开发者ID:johan--,项目名称:commcare-hq,代码行数:12,代码来源:test_exclusion.py

示例5: testDuplicateCasePropertiesBug

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    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] = FormProcessorInterface.submit_form_locally(xml_data)
        self.assertEqual("", case.foo)

        xml_data = self.get_xml('duplicate_case_properties_2')
        response, form, [case] = FormProcessorInterface.submit_form_locally(xml_data)
        self.assertEqual("2", case.bar)
开发者ID:johan--,项目名称:commcare-hq,代码行数:13,代码来源:test_bugs.py

示例6: testOutOfOrderSubmissions

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    def testOutOfOrderSubmissions(self):
        dir = os.path.join(os.path.dirname(__file__), "data", "ordering")
        for fname in ('update_oo.xml', 'create_oo.xml'):
            with open(os.path.join(dir, fname), "rb") as f:
                xml_data = f.read()

            FormProcessorInterface.submit_form_locally(xml_data)

        case = FormProcessorInterface.get_case('30bc51f6-3247-4966-b4ae-994f572e85fe')
        self.assertEqual('from the update form', case.pupdate)
        self.assertEqual('from the create form', case.pcreate)
        self.assertEqual('overridden by the update form', case.pboth)
开发者ID:johan--,项目名称:commcare-hq,代码行数:14,代码来源:test_out_of_order_processing.py

示例7: testCasesInRepeats

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
 def testCasesInRepeats(self):
     file_path = os.path.join(os.path.dirname(__file__), "data", "multicase", "case_in_repeats.xml")
     with open(file_path, "rb") as f:
         xml_data = f.read()
     _, form, cases = FormProcessorInterface.submit_form_locally(xml_data, domain=self.domain)
     self.assertEqual(3, len(cases))
     self._check_ids(form, cases)
开发者ID:johan--,项目名称:commcare-hq,代码行数:9,代码来源:test_multi_case_submits.py

示例8: test_empty_case_id

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
 def test_empty_case_id(self):
     """
     Ensure that form processor fails on empty id
     """
     xml_data = self.get_xml('empty_id')
     response, form, cases = FormProcessorInterface.submit_form_locally(xml_data)
     self.assertIn('IllegalCaseId', response.content)
开发者ID:johan--,项目名称:commcare-hq,代码行数:9,代码来源:test_bugs.py

示例9: testLotsOfSubcases

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
 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 = FormProcessorInterface.submit_form_locally(xml_data)
     self.assertEqual(11, len(cases))
开发者ID:johan--,项目名称:commcare-hq,代码行数:9,代码来源:test_bugs.py

示例10: testNestedExclusion

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
 def testNestedExclusion(self):
     """
     Blocks inside forms tagged as device logs should be excluded
     """
     file_path = os.path.join(os.path.dirname(__file__), "data", "exclusion", "nested_device_report.xml")
     with open(file_path, "rb") as f:
         xml_data = f.read()
     _, _, [case] = FormProcessorInterface.submit_form_locally(xml_data)
     self.assertEqual(1, get_total_case_count())
     self.assertEqual("form case", case.name)
开发者ID:johan--,项目名称:commcare-hq,代码行数:12,代码来源:test_exclusion.py

示例11: testMultipleCaseBlocks

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

示例12: _test

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

示例13: bootstrap_case_from_xml

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
def bootstrap_case_from_xml(test_class, filename, case_id_override=None, domain=None):
    starttime = utcnow_sans_milliseconds()
    
    file_path = os.path.join(os.path.dirname(__file__), "data", filename)
    with open(file_path, "rb") as f:
        xml_data = f.read()
    updated_xml, uid, case_id = _replace_ids_in_xform_xml(
        xml_data,
        case_id_override=case_id_override,
    )

    domain = domain or 'test-domain'
    _, _, [case] = FormProcessorInterface.submit_form_locally(updated_xml, domain=domain)
    test_class.assertLessEqual(starttime, case.server_modified_on)
    test_class.assertGreaterEqual(datetime.utcnow(), case.server_modified_on)
    test_class.assertEqual(case_id, case.id)
    return case
开发者ID:johan--,项目名称:commcare-hq,代码行数:19,代码来源:util.py

示例14: testRestoreAttributes

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    def testRestoreAttributes(self):
        file_path = os.path.join(os.path.dirname(__file__),
                                 "data", "attributes.xml")
        with open(file_path, "rb") as f:
            xml_data = f.read()
        _, _, [newcase] = FormProcessorInterface.submit_form_locally(xml_data, domain=self.project.name)

        self.assertTrue(isinstance(newcase.adate, dict))
        self.assertEqual(date(2012, 02, 01), newcase.adate["#text"])
        self.assertEqual("i am an attribute", newcase.adate["@someattr"])
        self.assertTrue(isinstance(newcase.dateattr, dict))
        self.assertEqual("this shouldn't break", newcase.dateattr["#text"])
        self.assertEqual(date(2012, 01, 01), newcase.dateattr["@somedate"])
        self.assertTrue(isinstance(newcase.stringattr, dict))
        self.assertEqual("neither should this", newcase.stringattr["#text"])
        self.assertEqual("i am a string", newcase.stringattr["@somestring"])
        restore_payload = generate_restore_payload(self.project, dummy_user())
        # ghetto
        self.assertTrue('<dateattr somedate="2012-01-01">' in restore_payload)
        self.assertTrue('<stringattr somestring="i am a string">' in restore_payload)
开发者ID:johan--,项目名称:commcare-hq,代码行数:22,代码来源:test_ota_restore.py

示例15: _test_sync_token

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import submit_form_locally [as 别名]
    def _test_sync_token(self, items):
        """
        Tests sync token / sync mode support
        """
        file_path = os.path.join(os.path.dirname(__file__),
                                 "data", "create_short.xml")
        with open(file_path, "rb") as f:
            xml_data = f.read()
        FormProcessorInterface.submit_form_locally(xml_data, domain=self.project.name)

        time.sleep(1)
        restore_payload = generate_restore_payload(self.project, dummy_user(), items=items)

        sync_log_id = SyncLog.view(
            "phone/sync_logs_by_user",
            include_docs=True,
            reduce=False
        ).one().get_id
        expected_restore_payload = dummy_restore_xml(
            sync_log_id,
            const.CREATE_SHORT,
            items=4 if items else None,
        )
        check_xml_line_by_line(self, expected_restore_payload, restore_payload)

        time.sleep(1)
        sync_restore_payload = generate_restore_payload(
            project=self.project,
            user=dummy_user(),
            restore_id=sync_log_id,
            items=items,
        )
        all_sync_logs = SyncLog.view(
            "phone/sync_logs_by_user",
            include_docs=True,
            reduce=False,
        ).all()
        [latest_log] = [log for log in all_sync_logs
                        if log.get_id != sync_log_id]

        # should no longer have a case block in the restore XML
        check_xml_line_by_line(
            self,
            dummy_restore_xml(latest_log.get_id, items=3 if items else None),
            sync_restore_payload,
        )

        # apply an update
        time.sleep(1)
        file_path = os.path.join(os.path.dirname(__file__),
                                 "data", "update_short.xml")
        with open(file_path, "rb") as f:
            xml_data = f.read()
        FormProcessorInterface.submit_form_locally(xml_data, domain=self.project.name)

        time.sleep(1)
        sync_restore_payload = generate_restore_payload(
            self.project,
            user=dummy_user(),
            restore_id=latest_log.get_id,
            items=items,
        )
        all_sync_logs = SyncLog.view(
            "phone/sync_logs_by_user",
            include_docs=True,
            reduce=False,
        ).all()
        [even_latest_log] = [log for log in all_sync_logs
                             if log.get_id != sync_log_id and
                             log.get_id != latest_log.get_id]

        # case block should come back
        expected_sync_restore_payload = dummy_restore_xml(
            even_latest_log.get_id,
            const.UPDATE_SHORT,
            items=4 if items else None,
        )
        check_xml_line_by_line(self, expected_sync_restore_payload,
                               sync_restore_payload)
开发者ID:johan--,项目名称:commcare-hq,代码行数:81,代码来源:test_ota_restore.py


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