本文整理匯總了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-'))
示例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
示例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)
示例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