forked from niwinz/django-sendsms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
39 lines (27 loc) · 1.03 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
import unittest
from django.conf import settings
import sendsms
if not settings.configured:
settings.configure(
SENDSMS_BACKEND = 'sendsms.backends.locmem.SmsBackend',
ESENDEX_USERNAME = 'niwibe',
ESENDEX_PASSWORD = '123123',
ESENDEX_ACCOUNT = '123123',
ESENDEX_SANDBOX = True,
)
class TestApi(unittest.TestCase):
def test_send_simple_sms(self):
from sendsms.message import SmsMessage
obj = SmsMessage(body="test", from_phone='111111111', to=['222222222'])
obj.send()
self.assertEqual(len(sendsms.outbox), 1)
def test_send_esendex_sandbox(self):
from sendsms.message import SmsMessage
from sendsms.api import get_connection
connection = get_connection('sendsms.backends.esendex.SmsBackend')
obj = SmsMessage(body="test", from_phone='111111111', to=['222222222'], connection=connection)
res = obj.send()
self.assertEqual(res, 1)
if __name__ == '__main__':
unittest.main(verbosity=2)