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


Python SMS.save方法代码示例

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


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

示例1: testSMSSync

# 需要导入模块: from corehq.apps.sms.models import SMS [as 别名]
# 或者: from corehq.apps.sms.models.SMS import save [as 别名]
    def testSMSSync(self):
        self.deleteAllLogs()
        self.assertEqual(self.getSMSLogCount(), 0)
        self.assertEqual(self.getSMSCount(), 0)

        # Test Create
        sms = SMS()
        self.setRandomSMSValues(sms)
        sms.save()

        sleep(1)
        self.assertEqual(self.getSMSLogCount(), 1)
        self.assertEqual(self.getSMSCount(), 1)

        smslog = FRISMSLog.get(sms.couch_id)
        self.checkFieldValues(smslog, sms, SMS._migration_get_fields())
        self.assertTrue(FRISMSLog.get_db().get_rev(smslog._id).startswith('2-'))

        # Test Update
        self.setRandomSMSValues(sms)
        sms.save()

        sleep(1)
        self.assertEqual(self.getSMSLogCount(), 1)
        self.assertEqual(self.getSMSCount(), 1)
        smslog = FRISMSLog.get(sms.couch_id)
        self.checkFieldValues(smslog, sms, SMS._migration_get_fields())
        self.assertTrue(FRISMSLog.get_db().get_rev(smslog._id).startswith('3-'))
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:30,代码来源:migration.py

示例2: _get_fake_sms

# 需要导入模块: from corehq.apps.sms.models import SMS [as 别名]
# 或者: from corehq.apps.sms.models.SMS import save [as 别名]
 def _get_fake_sms(self, text):
     msg = SMS(
         domain=self.domain,
         phone_number='+16175555454',
         direction=OUTGOING,
         date=datetime.utcnow(),
         backend_id=self.mobile_backend.couch_id,
         text=text
     )
     msg.save()
     return msg
开发者ID:,项目名称:,代码行数:13,代码来源:

示例3: remove_from_queue

# 需要导入模块: from corehq.apps.sms.models import SMS [as 别名]
# 或者: from corehq.apps.sms.models.SMS import save [as 别名]
def remove_from_queue(queued_sms):
    with transaction.atomic():
        sms = SMS()
        for field in sms._meta.fields:
            if field.name != 'id':
                setattr(sms, field.name, getattr(queued_sms, field.name))
        queued_sms.delete()
        sms.save()

    sms.publish_change()

    if sms.direction == OUTGOING and sms.processed and not sms.error:
        create_billable_for_sms(sms)
    elif sms.direction == INCOMING and sms.domain and domain_has_privilege(sms.domain, privileges.INBOUND_SMS):
        create_billable_for_sms(sms)
开发者ID:,项目名称:,代码行数:17,代码来源:

示例4: arbitrary_messages_by_backend_and_direction

# 需要导入模块: from corehq.apps.sms.models import SMS [as 别名]
# 或者: from corehq.apps.sms.models.SMS import save [as 别名]
def arbitrary_messages_by_backend_and_direction(backend_ids,
                                                phone_number=None,
                                                domain=None,
                                                directions=DIRECTIONS):
    phone_number = phone_number or TEST_NUMBER
    domain = domain or TEST_DOMAIN
    messages = []
    for api_id, instance_id in backend_ids.items():
        for direction in directions:
            sms_log = SMS(
                direction=direction,
                phone_number=phone_number,
                domain=domain,
                backend_api=api_id,
                backend_id=instance_id,
                text=arbitrary_message(),
                date=datetime.datetime.utcnow()
            )
            sms_log.save()
            messages.append(sms_log)
    return messages
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:23,代码来源:generator.py


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