本文整理汇总了Python中casexml.apps.case.models.CommCareCase.case_properties方法的典型用法代码示例。如果您正苦于以下问题:Python CommCareCase.case_properties方法的具体用法?Python CommCareCase.case_properties怎么用?Python CommCareCase.case_properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类casexml.apps.case.models.CommCareCase
的用法示例。
在下文中一共展示了CommCareCase.case_properties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MessageTestCase
# 需要导入模块: from casexml.apps.case.models import CommCareCase [as 别名]
# 或者: from casexml.apps.case.models.CommCareCase import case_properties [as 别名]
class MessageTestCase(BaseReminderTestCase):
def setUp(self):
self.domain = "test"
self.parent_case = CommCareCase(
domain=self.domain,
type="parent",
name="P001",
)
self.parent_case.set_case_property("parent_prop1", "abc")
self.parent_case.save()
self.child_case = CommCareCase(
domain=self.domain,
type="child",
name="P002",
indices=[CommCareCaseIndex(
identifier="parent",
referenced_type="parent",
referenced_id=self.parent_case._id,
)],
)
self.child_case.set_case_property("child_prop1", "def")
self.child_case.save()
def tearDown(self):
self.child_case.delete()
self.parent_case.delete()
def test_message(self):
message = 'The EDD for client with ID {case.external_id} is approaching in {case.edd.days_until} days.'
case = {'external_id': 123, 'edd': datetime.utcnow() + timedelta(days=30)}
outcome = 'The EDD for client with ID 123 is approaching in 30 days.'
self.assertEqual(Message.render(message, case=case), outcome)
def test_template_params(self):
child_result = {"case": self.child_case.case_properties()}
child_result["case"]["parent"] = self.parent_case.case_properties()
self.assertEqual(
get_message_template_params(self.child_case), child_result)
parent_result = {"case": self.parent_case.case_properties()}
parent_result["case"]["parent"] = {}
self.assertEqual(
get_message_template_params(self.parent_case), parent_result)