本文整理汇总了Python中casexml.apps.case.models.CommCareCase.set_db方法的典型用法代码示例。如果您正苦于以下问题:Python CommCareCase.set_db方法的具体用法?Python CommCareCase.set_db怎么用?Python CommCareCase.set_db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类casexml.apps.case.models.CommCareCase
的用法示例。
在下文中一共展示了CommCareCase.set_db方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import set_db [as 别名]
def setUp(self):
# we have to set the fake database before any other calls
self.orig_db = CommCareCase.get_db()
self.database = FakeCouchDb()
CommCareCase.set_db(self.database)
self.spec = {
"type": "related_doc",
"related_doc_type": "CommCareCase",
"doc_id_expression": {"type": "property_name", "property_name": "parent_id"},
"value_expression": {"type": "property_name", "property_name": "related_property"},
}
self.expression = ExpressionFactory.from_spec(self.spec)
self.nested_expression = ExpressionFactory.from_spec(
{
"type": "related_doc",
"related_doc_type": "CommCareCase",
"doc_id_expression": {"type": "property_name", "property_name": "parent_id"},
"value_expression": {
"type": "related_doc",
"related_doc_type": "CommCareCase",
"doc_id_expression": {"type": "property_name", "property_name": "parent_id"},
"value_expression": {"type": "property_name", "property_name": "related_property"},
},
}
)
示例2: setUp
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import set_db [as 别名]
def setUp(self):
self.database = FakeCouchDb()
self.case_orig_db = CommCareCase.get_db()
self.form_orig_db = XFormInstance.get_db()
self.user_orig_db = CommCareUser.get_db()
CommCareCase.set_db(self.database)
XFormInstance.set_db(self.database)
CommCareUser.set_db(self.database)
示例3: setUp
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import set_db [as 别名]
def setUp(self):
self.database = FakeCouchDb()
self.case_orig_db = CommCareCase.get_db()
self.form_orig_db = XFormInstance.get_db()
self.user_orig_db = CommCareUser.get_db()
CommCareCase.set_db(self.database)
XFormInstance.set_db(self.database)
CommCareUser.set_db(self.database)
self.factory = RequestFactory()
domain = Domain.get_or_create_with_name('up-nrhm')
domain.is_active = True
domain.save()
self.domain = domain
user = WebUser.get_by_username('test')
if not user:
user = WebUser.create(domain.name, 'test', 'passwordtest')
user.is_authenticated = True
user.is_superuser = True
user.is_authenticated = True
user.is_active = True
self.user = user
示例4: tearDown
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import set_db [as 别名]
def tearDown(self):
CommCareCase.set_db(self.orig_db)
示例5: tearDown
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import set_db [as 别名]
def tearDown(self):
CommCareCase.set_db(self.case_orig_db)
XFormInstance.set_db(self.form_orig_db)
CommCareUser.set_db(self.user_orig_db)