本文整理汇总了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)
示例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)