本文整理匯總了Python中corehq.form_processor.interfaces.FormProcessorInterface.soft_delete_case方法的典型用法代碼示例。如果您正苦於以下問題:Python FormProcessorInterface.soft_delete_case方法的具體用法?Python FormProcessorInterface.soft_delete_case怎麽用?Python FormProcessorInterface.soft_delete_case使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類corehq.form_processor.interfaces.FormProcessorInterface
的用法示例。
在下文中一共展示了FormProcessorInterface.soft_delete_case方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_deleted_indices_removed
# 需要導入模塊: from corehq.form_processor.interfaces import FormProcessorInterface [as 別名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import soft_delete_case [as 別名]
def test_deleted_indices_removed(self):
factory = CaseFactory(
self.domain,
case_defaults={
'user_id': self.commcare_user._id,
'owner_id': self.commcare_user._id,
'case_type': 'a-case',
'create': True,
},
)
# create a parent/child set of cases
parent_id, child_id = [uuid.uuid4().hex for i in range(2)]
child, parent = factory.create_or_update_case(CaseStructure(
case_id=child_id,
indices=[
CaseIndex(CaseStructure(case_id=parent_id))
]
))
# confirm the child has an index, and 1 form
self.assertEqual(1, len(child.indices))
self.assertEqual(parent_id, child.indices[0].referenced_id)
self.assertEqual(1, len(child.xform_ids))
# simulate parent deletion
FormProcessorInterface.soft_delete_case(parent_id)
# call the remove index task
remove_indices_from_deleted_cases(self.domain, [parent_id])
# check that the index is removed via a new form
child = CommCareCase.get(child_id)
self.assertEqual(0, len(child.indices))
self.assertEqual(2, len(child.xform_ids))
示例2: test_assign_bad_index_ref
# 需要導入模塊: from corehq.form_processor.interfaces import FormProcessorInterface [as 別名]
# 或者: from corehq.form_processor.interfaces.FormProcessorInterface import soft_delete_case [as 別名]
def test_assign_bad_index_ref(self):
# the case has to exist to create the index, but if we delete it later the assignment
# shouldn't fail
case = self._new_case()
case_with_bad_ref = self._new_case(index={"parent": ("person", case._id)})
FormProcessorInterface.soft_delete_case(case._id)
# this call previously failed
res = assign_case(case_with_bad_ref.id, self.primary_user._id, include_subcases=True, include_parent_cases=True)
self.assertEqual(2, len(res))
self.assertIn(case_with_bad_ref._id, res)
self.assertIn(case._id, res)