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


Python XFormPillow.change_transform方法代码示例

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


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

示例1: testXFormPillowSingleCaseProcess

# 需要导入模块: from corehq.pillows.xform import XFormPillow [as 别名]
# 或者: from corehq.pillows.xform.XFormPillow import change_transform [as 别名]
    def testXFormPillowSingleCaseProcess(self):
        """
        Test that xform pillow can process and cleanup a single xform with a case submission
        """
        xform = XFORM_SINGLE_CASE
        pillow = XFormPillow(create_index=False, online=False)
        changed = pillow.change_transform(xform)

        self.assertIsNone(changed['form']['case'].get('@date_modified'))
        self.assertIsNotNone(xform['form']['case']['@date_modified'])
开发者ID:NoahCarnahan,项目名称:commcare-hq,代码行数:12,代码来源:test_pillows_cases.py

示例2: test_get_list

# 需要导入模块: from corehq.pillows.xform import XFormPillow [as 别名]
# 或者: from corehq.pillows.xform.XFormPillow import change_transform [as 别名]
    def test_get_list(self):
        """
        Any form in the appropriate domain should be in the list from the API.
        """

        # The actual infrastructure involves saving to CouchDB, having PillowTop
        # read the changes and write it to ElasticSearch.

        # In order to test just the API code, we set up a fake XFormES (this should
        # really be a parameter to the XFormInstanceResource constructor)
        # and write the translated form directly; we are not trying to test
        # the ptop infrastructure.

        #the pillow is set to offline mode - elasticsearch not needed to validate
        pillow = XFormPillow(online=False)
        fake_xform_es = FakeXFormES()
        v0_4.MOCK_XFORM_ES = fake_xform_es

        backend_form = XFormInstance(xmlns = 'fake-xmlns',
                                     domain = self.domain.name,
                                     received_on = datetime.utcnow(),
                                     form = {
                                         '#type': 'fake-type',
                                         '@xmlns': 'fake-xmlns'
                                     })
        backend_form.save()
        translated_doc = pillow.change_transform(backend_form.to_json())
        fake_xform_es.add_doc(translated_doc['_id'], translated_doc)

        self.client.login(username=self.username, password=self.password)

        response = self.client.get(self.list_endpoint)
        self.assertEqual(response.status_code, 200)

        api_forms = simplejson.loads(response.content)['objects']
        self.assertEqual(len(api_forms), 1)

        api_form = api_forms[0]
        self.assertEqual(api_form['form']['@xmlns'], backend_form.xmlns)
        self.assertEqual(api_form['received_on'], backend_form.received_on.isoformat())

        backend_form.delete()
开发者ID:modonnell729,项目名称:commcare-hq,代码行数:44,代码来源:tests.py


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