8000 fixes #87 by adding dequeue to instance queue member · thomas0708/twilio-python@f3a433c · GitHub
[go: up one dir, main page]

Skip to content

Commit f3a433c

Browse files
author
Doug Black
committed
fixes twilio#87 by adding dequeue to instance queue member
1 parent 175239d commit f3a433c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

tests/test_members.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from mock import patch
22
from tools import create_mock_json
3-
from twilio.rest.resources import Members
3+
from twilio.rest.resources import Members, Member
44

55
QUEUE_SID = "QU1b9faddec3d54ec18488f86c83019bf0"
66
ACCOUNT_SID = "AC123"
@@ -11,6 +11,7 @@
1111
TWIML_URL = "example_twiml_url"
1212

1313
list_resource = Members(BASE_URI, AUTH)
14+
instance_resource = Member(list_resource, CALL_SID)
1415

1516

1617
@patch("twilio.rest.resources.base.make_twilio_request")
@@ -44,3 +45,14 @@ def test_members_dequeue_call(mock):
4445
list_resource.dequeue(TWIML_URL, call_sid=CALL_SID)
4546

4647
mock.assert_called_with("POST", uri, data={"Url": TWIML_URL}, auth=AUTH)
48+
49+
50+
@patch("twilio.rest.resources.base.make_twilio_request")
51+
def test_member_dequeue_call(mock):
52+
resp = create_mock_json("tests/resources/members_instance.json")
53+
mock.return_value = resp
54+
55+
uri = "%s/Members/%s" % (BASE_URI, CALL_SID)
56+
instance_resource.dequeue(TWIML_URL)
57+
58+
mock.assert_called_with("POST", uri, data={"Url": TWIML_URL}, auth=AUTH)

twilio/rest/resources/queues.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ class Member(InstanceResource):
2727

2828
id_key = "call_sid"
2929

30+
def dequeue(self, url, **kwargs):
31+
"""
32+
Dequeues this member from the queue and have the member's call
33+
begin executing the TwiML document at the url.
34+
35+
:param url: url of the TwiML document to be executed.
36+
"""
37+
kwargs['url'] = url
38+
return self.parent.update_instance(self.name, kwargs)
39+
3040

3141
class Members(ListResource):
3242
""" A list of :class:`Member` objects """

0 commit comments

Comments
 (0)
0