8000 Support for DELETE of Call records · AlbertoALopez/twilio-python@684fc12 · GitHub
[go: up one dir, main page]

Skip to content

Commit 684fc12

Browse files
committed
Support for DELETE of Call records
1 parent 4728fb0 commit 684fc12

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

tests/test_calls.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import date
2-
from mock import patch
2+
from mock import patch, Mock
33
from nose.tools import raises, assert_true
4-
from twilio.rest.resources import Calls
4+
from twilio.rest.resources import Calls, Call
55
from tools import create_mock_json
66

77
BASE_URI = "https://api.twilio.com/2010-04-01/Accounts/AC123"
@@ -82,6 +82,15 @@ def test_cancel(mock):
8282
assert_true(r)
8383

8484

85-
@raises(AttributeError)
86-
def test_create():
87-
list_resource.delete
85+
@patch("twilio.rest.resources.base.Resource.request")
86+
def test_delete(req):
87+
""" Deleting a call should work """
88+
resp = Mock()
89+
resp.content = ""
90+
resp.status_code = 204
91+
req.return_value = resp, {}
92+
93+
app = Call(list_resource, "CA123")
94+
app.delete()
95+
uri = "https://api.twilio.com/2010-04-01/Accounts/AC123/Calls/CA123"
96+
req.assert_called_with("DELETE", uri)

twilio/rest/resources/calls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def route(self, **kwargs):
5050
a = self.parent.route(self.name, **kwargs)
5151
self.load(a.__dict__)
5252

53+
def delete(self):
54+
"""Delete the specified :class:`Call` record from Twilio."""
55+
return self.parent.delete(self.name)
56+
5357

5458
class Calls(ListResource):
5559
""" A list of Call resources """
@@ -169,3 +173,7 @@ def feedback(self, sid, quality_score, issue=None):
169173
return call_feedback_factory.create(
170174
quality_score=quality_score, issue=issue
171175
)
176+
177+
def delete(self, sid):
178+
"""Delete the given Call record from Twilio."""
179+
return self.delete_instance(sid)

0 commit comments

Comments
 (0)
0