forked from twilio/twilio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_queues.py
70 lines (49 loc) · 2.13 KB
/
test_queues.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
59
60
61
62
63
64
65
66
67
68
69
70
from mock import patch
from tools import create_mock_json
from twilio.rest.resources import Queues, Queue
BASE_URI = "https://api.twilio.com/2010-04-01/Accounts/AC123"
ACCOUNT_SID = "AC123"
AUTH = (ACCOUNT_SID, "token")
QUEUE_SID = "QU1b9faddec3d54ec18488f86c83019bf0"
CALL_SID = "CAaaf2e9ded94aba3e57c42a3d55be6ff2"
list_resource = Queues(BASE_URI, AUTH)
instance_resource = Queue(list_resource, QUEUE_SID)
@patch("twilio.rest.resources.base.make_twilio_request")
def test_queues_list(mock):
resp = create_mock_json("tests/resources/queues_list.json")
mock.return_value = resp
uri = "%s/Queues" % (BASE_URI)
list_resource.list()
mock.assert_called_with("GET", uri, params={}, auth=AUTH)
@patch("twilio.rest.resources.base.make_twilio_request")
def test_queues_create(mock):
resp = create_mock_json("tests/resources/queues_instance.json")
resp.status_code = 201
mock.return_value = resp
uri = "%s/Queues" % (BASE_URI)
list_resource.create('test', max_size=9001)
mock.assert_called_with("POST", uri,
data={'FriendlyName': 'test', 'MaxSize': 9001},
auth=AUTH)
@patch("twilio.rest.resources.base.make_twilio_request")
def test_queues_get(mock):
resp = create_mock_json("tests/resources/queues_instance.json")
mock.return_value = resp
uri = "%s/Queues/%s" % (BASE_URI, QUEUE_SID)
list_resource.get(QUEUE_SID)
mock.assert_called_with("GET", uri, auth=AUTH)
@patch("twilio.rest.resources.base.make_twilio_request")
def test_queue_update(mock):
resp = create_mock_json("tests/resources/queues_instance.json")
mock.return_value = resp
uri = "%s/Queues/%s" % (BASE_URI, QUEUE_SID)
instance_resource.update(friendly_name='QQ')
mock.assert_called_with("POST", uri,
data={'FriendlyName': 'QQ'}, auth=AUTH)
@patch("twilio.rest.resources.base.make_twilio_request")
def test_queue_delete(mock):
resp = create_mock_json("tests/resources/queues_instance.json")
mock.return_value = resp
uri = "%s/Queues/%s" % (BASE_URI, QUEUE_SID)
instance_resource.delete()
mock.assert_called_with("DELETE", uri, auth=AUTH)