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


Python SQLXFormsSession.get_all_open_sms_sessions方法代码示例

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


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

示例1: test_get_and_close_all_open_sessions

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
    def test_get_and_close_all_open_sessions(self):
        domain = uuid.uuid4().hex
        contact = uuid.uuid4().hex
        for i in range(3):
            _make_session(
                domain=domain,
                connection_id=contact,
                end_time=None,
                session_type=XFORMS_SESSION_SMS,
            )

        sql_sessions = SQLXFormsSession.get_all_open_sms_sessions(domain, contact)
        self.assertEqual(3, len(sql_sessions))
        SQLXFormsSession.close_all_open_sms_sessions(domain, contact)
        self.assertEqual(0, len(SQLXFormsSession.get_all_open_sms_sessions(domain, contact)))
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:17,代码来源:test_sql_session.py

示例2: test_get_all_open_sessions_wrong_type

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
 def test_get_all_open_sessions_wrong_type(self):
     domain = uuid.uuid4().hex
     contact = uuid.uuid4().hex
     _make_session(
         domain=domain,
         connection_id=contact,
         end_time=None,
         session_type=XFORMS_SESSION_IVR,
     )
     self.assertEqual(0, len(SQLXFormsSession.get_all_open_sms_sessions(domain, contact)))
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:12,代码来源:test_sql_session.py

示例3: test_get_all_open_sessions_already_ended

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
 def test_get_all_open_sessions_already_ended(self):
     domain = uuid.uuid4().hex
     contact = uuid.uuid4().hex
     _make_session(
         domain=domain,
         connection_id=contact,
         end_time=datetime.utcnow(),
         session_type=XFORMS_SESSION_SMS,
     )
     self.assertEqual(0, len(SQLXFormsSession.get_all_open_sms_sessions(domain, contact)))
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:12,代码来源:test_sql_session.py

示例4: test_get_all_open_sessions_contact_mismatch

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
 def test_get_all_open_sessions_contact_mismatch(self):
     domain = uuid.uuid4().hex
     contact = uuid.uuid4().hex
     _make_session(
         domain=domain,
         connection_id='wrong',
         end_time=None,
         session_is_open=True,
         session_type=XFORMS_SESSION_SMS,
     )
     self.assertEqual(0, len(SQLXFormsSession.get_all_open_sms_sessions(domain, contact)))
开发者ID:dimagi,项目名称:commcare-hq,代码行数:13,代码来源:test_sql_session.py

示例5: sms_keyword_handler

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
def sms_keyword_handler(v, text, msg):
    text = text.strip()
    if text == "":
        return False

    sessions = SQLXFormsSession.get_all_open_sms_sessions(v.domain, v.owner_id)
    text_words = text.upper().split()

    if text.startswith("#"):
        return handle_global_keywords(v, text, msg, text_words, sessions)
    else:
        return handle_domain_keywords(v, text, msg, text_words, sessions)
开发者ID:johan--,项目名称:commcare-hq,代码行数:14,代码来源:keyword.py

示例6: test_get_single_open_session

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
 def test_get_single_open_session(self):
     properties = _arbitrary_session_properties(
         end_time=None,
         session_type=XFORMS_SESSION_SMS,
     )
     session = SQLXFormsSession(**properties)
     session.save()
     (mult, session) = get_single_open_session_or_close_multiple(
         session.domain, session.connection_id
     )
     self.assertEqual(False, mult)
     [session_back] = SQLXFormsSession.get_all_open_sms_sessions(
         session.domain, session.connection_id
     )
     self.assertEqual(session._id, session_back.couch_id)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:17,代码来源:test_sql_session.py

示例7: test_get_single_open_session_close_multiple

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
    def test_get_single_open_session_close_multiple(self):
        domain = uuid.uuid4().hex
        contact = uuid.uuid4().hex
        for i in range(3):
            _make_session(
                domain=domain,
                connection_id=contact,
                end_time=None,
                session_type=XFORMS_SESSION_SMS,
            )

        (mult, session) = get_single_open_session_or_close_multiple(domain, contact)
        self.assertEqual(True, mult)
        self.assertEqual(None, session)
        self.assertEqual(0, len(SQLXFormsSession.get_all_open_sms_sessions(domain, contact)))
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:17,代码来源:test_sql_session.py

示例8: get_single_open_session_or_close_multiple

# 需要导入模块: from corehq.apps.smsforms.models import SQLXFormsSession [as 别名]
# 或者: from corehq.apps.smsforms.models.SQLXFormsSession import get_all_open_sms_sessions [as 别名]
def get_single_open_session_or_close_multiple(domain, contact_id):
    """
    Retrieves the current open SQLXFormsSession for the given contact.
    If multiple sessions are open, it closes all of them and returns
    None for the session.

    The return value is a tuple of (multiple, session), where multiple
    is True if there were multiple sessions, and session is the session if
    there was a single open session available.
    """
    sessions = SQLXFormsSession.get_all_open_sms_sessions(domain, contact_id)
    count = sessions.count()
    if count > 1:
        for session in sessions:
            session.end(False)
            session.save()
        return (True, None)

    session = sessions[0] if count == 1 else None
    return (False, session)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:22,代码来源:form_session.py


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