forked from twilio/twilio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_applications.py
58 lines (44 loc) · 1.92 KB
/
test_applications.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import six
if six.PY3:
import unittest
else:
import unittest2 as unittest
from mock import Mock
from twilio.rest.resources import Applications
class ApplicationsTest(unittest.TestCase):
def setUp(self):
self.parent = Mock()
self.resource = Applications("http://api.twilio.com", ("user", "pass"))
def test_create_appliation_sms_url_method(self):
self.resource.create_instance = Mock()
self.resource.create(sms_method="hey")
self.resource.create_instance.assert_called_with({"sms_method": "hey"})
def test_create_appliation_sms_url(self):
self.resource.create_instance = Mock()
self.resource.create(sms_url="hey")
self.resource.create_instance.assert_called_with({"sms_url": "hey"})
def test_update_appliation_sms_url_method(self):
self.resource.update_instance = Mock()
self.resource.update("123", sms_method="hey")
self.resource.update_instance.assert_called_with(
"123", {"sms_method": "hey"})
def test_update_appliation_sms_url(self):
self.resource.update_instance = Mock()
self.resource.update("123", sms_url="hey")
self.resource.update_instance.assert_called_with(
"123", {"sms_url": "hey"})
def test_update(self):
request = Mock()
request.return_value = (Mock(), {"sid": "123"})
self.resource.request = request
self.resource.update("123", voice_url="hey")
uri = "http://api.twilio.com/Applications/123"
request.assert_called_with("POST", uri, data={"VoiceUrl": "hey"})
def test_create(self):
request = Mock()
request.return_value = (request, {"sid": "123"})
request.status_code = 201
self.resource.request = request
self.resource.create(friendly_name="hey")
uri = "http://api.twilio.com/Applications"
request.assert_called_with("POST", uri, data={"FriendlyName": "hey"})