示例#1
0
def PersonSendSmsView(request):
    TWILIO_MAGIC_FROM_NUMBER = "+15005550006"
    VALID_FROM_NUMBER = TWILIO_MAGIC_FROM_NUMBER
    VALID_TO_NUMBER = TWILIO_MAGIC_FROM_NUMBER
    sms = SMSMessage("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])
    sms.send()

    send_sms("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])

    return render(request, 'sms_sent.html')
示例#2
0
	def test_send_sms(self):
		with captured_stdout() as stdout:
			numSent = send_sms("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])
			self.assertEqual(numSent, 1)
			self.assertEqual(len(mail.outbox), 0)
			output = stdout.getvalue()
			self.assertTrue("Subject: None" in output)
			self.assertTrue("From: +15005550006" in output)
			self.assertTrue("To: +15005550006" in output)
			self.assertTrue("Body" in output)
示例#3
0
def send_alert_sms(details):

    from_number = settings.TWILIO_FROM_NUMBER

    try:
        user = details['user']
        recipients = (user['phone_number'], )
        email = user['email']
    except KeyError:
        logger.error('SMS alert details missing phone number! - %s', details)
        return

    try:
        team = details.get('team_name', 'your team')
        loc = details.get('location', None)
        gtime = details.get('gametime', None)
        ana = 'an' if loc == 'away' else 'a'
        msg = 'Sports Warning! {team} are playing {ana} {loc} game {gtime}.'.format(
            team=team, ana=ana, loc=loc, gtime=gtime)
    except KeyError:
        logger.error('KeyError in sms alert %s', details)
        msg = 'Sports Warning! One of your warnings was triggered but we failed.  Look out for sports today!'
    msg += ' - sportswarning.com via {}'.format(email)
    send_sms(msg, from_number, recipients)
示例#4
0
	def test_send_sms(self):
		numSent = send_sms("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])
		self.assertEqual(numSent, 1)
		self.assertEqual(len(mail.outbox), 0)
示例#5
0
	def test_send_sms(self):
		with self.assertRaises(AssertionError):
			numSent = send_sms("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])
			self.assertEqual(numSent, 1)
			self.assertEqual(len(mail.outbox), 1)
示例#6
0
	def test_send_sms(self):
		results = send_sms("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER])
		self.assertEqual(results, [1])
		self.assertEqual(len(mail.outbox), 1)
示例#7
0
def async_send_single_msg(phone, message):
    send_sms(message, VALID_FROM_NUMBER, (phone, ))