def test_send_mass_sms(self): from smsish.sms import get_sms_connection with get_sms_connection(settings.SMS_BACKEND) as connection: datatuple = (("Body", VALID_FROM_NUMBER, [VALID_TO_NUMBER]) for _ in range(10)) numSent = send_mass_sms(datatuple, connection=connection) self.assertEqual(numSent, 10) self.assertEqual(len(mail.outbox), 0)
def send_sms_message(sms_message, backend=None, fail_silently=False): """ Send an SMSMessage instance using a connection given by the specified `backend`. """ with get_sms_connection(backend=backend, fail_silently=fail_silently) as connection: result = connection.send_messages([sms_message]) return result
def test_send_with_connection(self): # from django.conf import settings from smsish.sms import get_sms_connection sms = self.get_new_sms_message() with get_sms_connection() as connection: jobs = connection.send_messages([sms]) self.assertEqual(len(jobs), 1) # http://python-rq.org/docs/testing/ # https://github.com/ui/django-rq#testing-tip self.assertEqual(len(mail.outbox), 1) self.process_jobs() for job in jobs: self.assertTrue(job.id) self.assertEqual(job.args[0].body, sms.body)