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


Python FormProcessorInterface.archive_xform方法代码示例

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


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

示例1: testSignal

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import archive_xform [as 别名]
    def testSignal(self):
        global archive_counter, restore_counter
        archive_counter = 0
        restore_counter = 0

        def count_archive(**kwargs):
            global archive_counter
            archive_counter += 1

        def count_unarchive(**kwargs):
            global restore_counter
            restore_counter += 1

        xform_archived.connect(count_archive)
        xform_unarchived.connect(count_unarchive)

        xform = FormProcessorInterface.create_from_generic(
            GenericXFormInstance(form={'foo': 'bar'}),
            GenericFormAttachment(name='form.xml', content='<data/>')
        )

        self.assertEqual(0, archive_counter)
        self.assertEqual(0, restore_counter)

        FormProcessorInterface.archive_xform(xform)
        self.assertEqual(1, archive_counter)
        self.assertEqual(0, restore_counter)

        FormProcessorInterface.unarchive_xform(xform)
        self.assertEqual(1, archive_counter)
        self.assertEqual(1, restore_counter)
开发者ID:johan--,项目名称:commcare-hq,代码行数:33,代码来源:test_archive.py

示例2: testArchive

# 需要导入模块: from corehq.form_processor.interfaces import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import archive_xform [as 别名]
    def testArchive(self):
        xform = FormProcessorInterface.create_from_generic(
            GenericXFormInstance(form={'foo': 'bar'}),
            GenericFormAttachment(name='form.xml', content='<data/>')
        )

        self.assertEqual("XFormInstance", xform.doc_type)
        self.assertEqual(0, len(xform.history))

        lower_bound = datetime.utcnow() - timedelta(seconds=1)
        FormProcessorInterface.archive_xform(xform, user='mr. librarian')
        upper_bound = datetime.utcnow() + timedelta(seconds=1)

        xform = FormProcessorInterface.get_xform(xform.id)
        self.assertEqual('XFormArchived', xform.doc_type)

        [archival] = xform.history
        self.assertTrue(lower_bound <= archival.date <= upper_bound)
        self.assertEqual('archive', archival.operation)
        self.assertEqual('mr. librarian', archival.user)

        lower_bound = datetime.utcnow() - timedelta(seconds=1)
        FormProcessorInterface.unarchive_xform(xform, user='mr. researcher')
        upper_bound = datetime.utcnow() + timedelta(seconds=1)

        xform = FormProcessorInterface.get_xform(xform.id)
        self.assertEqual('XFormInstance', xform.doc_type)

        [archival, restoration] = xform.history
        self.assertTrue(lower_bound <= restoration.date <= upper_bound)
        self.assertEqual('unarchive', restoration.operation)
        self.assertEqual('mr. researcher', restoration.user)
开发者ID:johan--,项目名称:commcare-hq,代码行数:34,代码来源:test_archive.py


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