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


Python FormAccessorSQL.get_form方法代码示例

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


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

示例1: _validate_deprecation

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
 def _validate_deprecation(self, existing_form, new_form):
     saved_new_form = FormAccessorSQL.get_form(new_form.form_id)
     deprecated_form = FormAccessorSQL.get_form(existing_form.form_id)
     self.assertEqual(deprecated_form.form_id, saved_new_form.deprecated_form_id)
     self.assertTrue(deprecated_form.is_deprecated)
     self.assertNotEqual(saved_new_form.form_id, deprecated_form.form_id)
     self.assertEqual(saved_new_form.form_id, deprecated_form.orig_id)
开发者ID:,项目名称:,代码行数:9,代码来源:

示例2: test_archive_unarchive_form

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
    def test_archive_unarchive_form(self):
        case_id = uuid.uuid4().hex
        form = create_form_for_test(DOMAIN, case_id=case_id)
        self.assertEqual(XFormInstanceSQL.NORMAL, form.state)
        self.assertEqual(0, len(form.history))

        transactions = CaseAccessorSQL.get_transactions(case_id)
        self.assertEqual(1, len(transactions))
        self.assertFalse(transactions[0].revoked)

        FormAccessorSQL.archive_form(form, 'user1')
        form = FormAccessorSQL.get_form(form.form_id)
        self.assertEqual(XFormInstanceSQL.ARCHIVED, form.state)
        operations = form.history
        self.assertEqual(1, len(operations))
        self.assertEqual(form.form_id, operations[0].form_id)
        self.assertEqual('user1', operations[0].user_id)

        transactions = CaseAccessorSQL.get_transactions(case_id)
        self.assertEqual(1, len(transactions))
        self.assertTrue(transactions[0].revoked)

        FormAccessorSQL.unarchive_form(form, 'user2')
        form = FormAccessorSQL.get_form(form.form_id)
        self.assertEqual(XFormInstanceSQL.NORMAL, form.state)
        operations = form.history
        self.assertEqual(2, len(operations))
        self.assertEqual(form.form_id, operations[1].form_id)
        self.assertEqual('user2', operations[1].user_id)

        transactions = CaseAccessorSQL.get_transactions(case_id)
        self.assertEqual(1, len(transactions))
        self.assertFalse(transactions[0].revoked)
开发者ID:,项目名称:,代码行数:35,代码来源:

示例3: 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_form [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())
开发者ID:,项目名称:,代码行数:28,代码来源:

示例4: 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_form [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())
开发者ID:dimagi,项目名称:commcare-hq,代码行数:32,代码来源:test_form_dbaccessor.py

示例5: form

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
 def form(self):
     from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL
     if not self.form_id:
         return None
     form = getattr(self, 'cached_form', None)
     if not form:
         self.cached_form = FormAccessorSQL.get_form(self.form_id)
     return self.cached_form
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:10,代码来源:models.py

示例6: _simulate_form_edit

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
def _simulate_form_edit():
    existing_form = create_form_for_test(DOMAIN, save=False)
    FormAccessorSQL.save_new_form(existing_form)
    existing_form = FormAccessorSQL.get_form(existing_form.form_id)

    new_form = create_form_for_test(DOMAIN, save=False)
    new_form.form_id = existing_form.form_id

    existing_form, new_form = apply_deprecation(existing_form, new_form)
    assert existing_form.form_id != new_form.form_id
    return existing_form, new_form
开发者ID:,项目名称:,代码行数:13,代码来源:

示例7: _get_form

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
def _get_form(form_id):
    from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL
    from corehq.form_processor.backends.couch.dbaccessors import FormAccessorCouch
    try:
        return FormAccessorSQL.get_form(form_id)
    except XFormNotFound:
        pass

    try:
        return FormAccessorCouch.get_form(form_id)
    except ResourceNotFound:
        pass

    return None
开发者ID:dimagi,项目名称:commcare-hq,代码行数:16,代码来源:reprocess.py

示例8: test_update_form_problem_and_state

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
    def test_update_form_problem_and_state(self):
        form = create_form_for_test(DOMAIN)
        self.assertEqual(XFormInstanceSQL.NORMAL, form.state)

        original_domain = form.domain
        problem = 'Houston, we have a problem'
        form.state = XFormInstanceSQL.ERROR
        form.problem = problem
        form.domain = 'new domain'  # shouldn't get saved
        FormAccessorSQL.update_form_problem_and_state(form)

        saved_form = FormAccessorSQL.get_form(form.form_id)
        self.assertEqual(XFormInstanceSQL.ERROR, saved_form.state)
        self.assertEqual(problem, saved_form.problem)
        self.assertEqual(original_domain, saved_form.domain)
开发者ID:,项目名称:,代码行数:17,代码来源:

示例9: test_update_form

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
    def test_update_form(self):
        form = create_form_for_test(DOMAIN)
        form.user_id = 'user2'
        operation_date = datetime.utcnow()
        form.track_create(XFormOperationSQL(
            user_id='user2',
            date=operation_date,
            operation=XFormOperationSQL.EDIT
        ))
        FormAccessorSQL.update_form(form)

        saved_form = FormAccessorSQL.get_form(form.form_id)
        self.assertEqual('user2', saved_form.user_id)
        self.assertEqual(1, len(saved_form.history))
        self.assertEqual(operation_date, saved_form.history[0].date)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:17,代码来源:test_form_dbaccessor.py

示例10: test_get_with_attachments

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
    def test_get_with_attachments(self):
        form = create_form_for_test(DOMAIN)
        form = FormAccessorSQL.get_form(form.form_id)  # refetch to clear cached attachments
        form_db = get_db_alias_for_partitioned_doc(form.form_id)
        with self.assertNumQueries(1, using=form_db):
            form.get_attachment_meta('form.xml')

        with self.assertNumQueries(1, using=form_db):
            form.get_attachment_meta('form.xml')

        with self.assertNumQueries(2, using=form_db):
            form = FormAccessorSQL.get_with_attachments(form.form_id)

        self._check_simple_form(form)
        with self.assertNumQueries(0, using=form_db):
            attachment_meta = form.get_attachment_meta('form.xml')

        self.assertEqual(form.form_id, attachment_meta.parent_id)
        self.assertEqual('form.xml', attachment_meta.name)
        self.assertEqual('text/xml', attachment_meta.content_type)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:22,代码来源:test_form_dbaccessor.py

示例11: get_obj_by_id

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
 def get_obj_by_id(cls, form_id):
     from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL
     return FormAccessorSQL.get_form(form_id)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:5,代码来源:models.py

示例12: test_get_form_by_id_missing

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
 def test_get_form_by_id_missing(self):
     with self.assertRaises(XFormNotFound):
         FormAccessorSQL.get_form('missing_form')
开发者ID:,项目名称:,代码行数:5,代码来源:

示例13: test_get_form_by_id

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
 def test_get_form_by_id(self):
     form = create_form_for_test(DOMAIN)
     with self.assertNumQueries(1, using=db_for_read_write(XFormInstanceSQL)):
         form = FormAccessorSQL.get_form(form.form_id)
     self._check_simple_form(form)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例14: test_get_form_by_id

# 需要导入模块: from corehq.form_processor.backends.sql.dbaccessors import FormAccessorSQL [as 别名]
# 或者: from corehq.form_processor.backends.sql.dbaccessors.FormAccessorSQL import get_form [as 别名]
 def test_get_form_by_id(self):
     form = create_form_for_test(DOMAIN)
     with self.assertNumQueries(1, using=form.db):
         form = FormAccessorSQL.get_form(form.form_id)
     self._check_simple_form(form)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:7,代码来源:test_form_dbaccessor.py


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