本文整理汇总了Python中corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL.get_forms方法的典型用法代码示例。如果您正苦于以下问题:Python FormAccessorSQL.get_forms方法的具体用法?Python FormAccessorSQL.get_forms怎么用?Python FormAccessorSQL.get_forms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL
的用法示例。
在下文中一共展示了FormAccessorSQL.get_forms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hard_delete_forms_and_attachments
# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_forms [as 别名]
def test_hard_delete_forms_and_attachments(self):
forms = [create_form_for_test(DOMAIN) for i in range(3)]
form_ids = [form.form_id for form in forms]
forms = FormAccessorSQL.get_forms(form_ids)
self.assertEqual(3, len(forms))
other_form = create_form_for_test('other_domain')
self.addCleanup(lambda: FormAccessorSQL.hard_delete_forms('other_domain', [other_form.form_id]))
attachments = list(FormAccessorSQL.get_attachments_for_forms(form_ids, ordered=True))
self.assertEqual(3, len(attachments))
deleted = FormAccessorSQL.hard_delete_forms(DOMAIN, form_ids[1:] + [other_form.form_id])
self.assertEqual(2, deleted)
forms = FormAccessorSQL.get_forms(form_ids)
self.assertEqual(1, len(forms))
self.assertEqual(form_ids[0], forms[0].form_id)
for attachment in attachments[1:]:
with self.assertRaises(AttachmentNotFound):
attachment.read_content()
self.assertIsNotNone(attachments[0].read_content())
other_form = FormAccessorSQL.get_form(other_form.form_id)
self.assertIsNotNone(other_form.get_xml())
示例2: test_hard_delete_forms_and_attachments
# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_forms [as 别名]
def test_hard_delete_forms_and_attachments(self):
forms = [create_form_for_test(DOMAIN) for i in range(3)]
form_ids = sorted(form.form_id for form in forms)
forms = FormAccessorSQL.get_forms(form_ids)
self.assertEqual(3, len(forms))
other_form = create_form_for_test('other_domain')
self.addCleanup(lambda: FormAccessorSQL.hard_delete_forms('other_domain', [other_form.form_id]))
attachments = sorted(
get_blob_db().metadb.get_for_parents(form_ids),
key=lambda meta: meta.parent_id
)
self.assertEqual(3, len(attachments))
deleted = FormAccessorSQL.hard_delete_forms(DOMAIN, form_ids[1:] + [other_form.form_id])
self.assertEqual(2, deleted)
forms = FormAccessorSQL.get_forms(form_ids)
self.assertEqual(1, len(forms))
self.assertEqual(form_ids[0], forms[0].form_id)
for attachment in attachments[1:]:
with self.assertRaises(BlobNotFound):
attachment.open()
with attachments[0].open() as content:
self.assertIsNotNone(content.read())
other_form = FormAccessorSQL.get_form(other_form.form_id)
self.assertIsNotNone(other_form.get_xml())
示例3: test_hard_delete_forms
# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_forms [as 别名]
def test_hard_delete_forms(self):
forms = [create_form_for_test(DOMAIN) for i in range(3)]
form_ids = [form.form_id for form in forms]
other_form = create_form_for_test('other_domain')
self.addCleanup(lambda: FormAccessorSQL.hard_delete_forms('other_domain', [other_form.form_id]))
forms = FormAccessorSQL.get_forms(form_ids)
self.assertEqual(3, len(forms))
deleted = FormAccessorSQL.hard_delete_forms(DOMAIN, form_ids[1:] + [other_form.form_id])
self.assertEqual(2, deleted)
forms = FormAccessorSQL.get_forms(form_ids)
self.assertEqual(1, len(forms))
self.assertEqual(form_ids[0], forms[0].form_id)
示例4: test_get_forms
# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_forms [as 别名]
def test_get_forms(self):
form1 = create_form_for_test(DOMAIN)
form2 = create_form_for_test(DOMAIN)
forms = FormAccessorSQL.get_forms(['missing_form'])
self.assertEqual(0, len(forms))
forms = FormAccessorSQL.get_forms([form1.form_id])
self.assertEqual(1, len(forms))
self.assertEqual(form1.form_id, forms[0].form_id)
forms = FormAccessorSQL.get_forms([form1.form_id, form2.form_id], ordered=True)
self.assertEqual(2, len(forms))
self.assertEqual(form1.form_id, forms[0].form_id)
self.assertEqual(form2.form_id, forms[1].form_id)
示例5: iter_all_changes
# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_forms [as 别名]
def iter_all_changes(self, start_from=None):
if not self.domains:
return
for form_id_chunk in self._iter_form_id_chunks():
for form in FormAccessorSQL.get_forms(form_id_chunk):
yield Change(
id=form.form_id,
sequence_id=None,
document=form.to_json(),
deleted=False,
metadata=change_meta_from_sql_form(form),
document_store=None,
)