本文整理汇总了Python中corehq.apps.smsforms.models.XFormsSession.save方法的典型用法代码示例。如果您正苦于以下问题:Python XFormsSession.save方法的具体用法?Python XFormsSession.save怎么用?Python XFormsSession.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.smsforms.models.XFormsSession
的用法示例。
在下文中一共展示了XFormsSession.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sync_from_creation
# 需要导入模块: from corehq.apps.smsforms.models import XFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.XFormsSession import save [as 别名]
def test_sync_from_creation(self):
properties = _arbitrary_session_properties()
couch_session = XFormsSession(**properties)
couch_session.save()
sql_session = SQLXFormsSession.objects.get(couch_id=couch_session._id)
for prop, value in properties.items():
self.assertEqual(getattr(sql_session, prop), value)
# make sure we didn't do any excess saves
self.assertTrue(XFormsSession.get_db().get_rev(couch_session._id).startswith('1-'))
示例2: test_sync_from_update
# 需要导入模块: from corehq.apps.smsforms.models import XFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.XFormsSession import save [as 别名]
def test_sync_from_update(self):
properties = _arbitrary_session_properties()
couch_session = XFormsSession(**properties)
couch_session.save()
sql_session = SQLXFormsSession.objects.get(couch_id=couch_session._id)
for prop, value in properties.items():
self.assertEqual(getattr(sql_session, prop), value)
previous_count = SQLXFormsSession.objects.count()
updated_properties = _arbitrary_session_properties()
for attr, val in updated_properties.items():
couch_session[attr] = val
couch_session.save()
# make sure nothing new was created
self.assertEqual(previous_count, SQLXFormsSession.objects.count())
# check updated props in the sql model
sql_session = SQLXFormsSession.objects.get(pk=sql_session.pk)
for prop, value in updated_properties.items():
self.assertEqual(getattr(sql_session, prop), value)
示例3: test_get_single_open_session
# 需要导入模块: from corehq.apps.smsforms.models import XFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.XFormsSession import save [as 别名]
def test_get_single_open_session(self):
properties = _arbitrary_session_properties(
end_time=None,
session_type=XFORMS_SESSION_SMS,
)
couch_session = XFormsSession(**properties)
couch_session.save()
(mult, session) = get_single_open_session_or_close_multiple(
couch_session.domain, couch_session.connection_id
)
self.assertEqual(False, mult)
self.assertEqual(couch_session._id, session._id)
[couch_session_back] = XFormsSession.get_all_open_sms_sessions(
couch_session.domain, couch_session.connection_id
)
[sql_session] = SQLXFormsSession.get_all_open_sms_sessions(
couch_session.domain, couch_session.connection_id
)
self.assertEqual(couch_session._id, couch_session_back._id)
self.assertEqual(couch_session._id, sql_session.couch_id)
示例4: _make_session
# 需要导入模块: from corehq.apps.smsforms.models import XFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.XFormsSession import save [as 别名]
def _make_session(**kwargs):
properties = _arbitrary_session_properties(**kwargs)
couch_session = XFormsSession(**properties)
couch_session.save()
return couch_session