8000 Allow Reject verb to be nested in Response; added addReject(); added … · isbo/twilio-python@c69ab44 · GitHub
[go: up one dir, main page]

Sk 8000 ip to content

Commit c69ab44

Browse files
author
isbo
committed
Allow Reject verb to be nested in Response; added addReject(); added unit tests
1 parent a6f6c40 commit c69ab44

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

tests/twimltests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def improperAppend(self, verb):
1212
self.assertRaises(twilio.TwilioException, verb.append, twilio.Play(""))
1313
self.assertRaises(twilio.TwilioException, verb.append, twilio.Record())
1414
self.assertRaises(twilio.TwilioException, verb.append, twilio.Hangup())
15+
self.assertRaises(twilio.TwilioException, verb.append, twilio.Reject())
1516
self.assertRaises(twilio.TwilioException, verb.append, twilio.Redirect())
1617
self.assertRaises(twilio.TwilioException, verb.append, twilio.Dial())
1718
self.assertRaises(twilio.TwilioException, verb.append, twilio.Conference(""))
@@ -213,6 +214,27 @@ def testBadAppend(self):
213214
""" should raise exceptions for wrong appending"""
214215
self.improperAppend(twilio.Hangup())
215216

217+
218+
class TestReject(TwilioTest):
219+
220+
def testReject(self):
221+
"""should be a Reject with default reason"""
222+
r = twilio.Response()
223+
r.append(twilio.Reject())
224+
r = self.strip(r)
225+
self.assertEquals(r, '<Response><Reject/></Response>')
226+
227+
def testRejectConvenience(self):
228+
"""should be a Reject with reason Busy"""
229+
r = twilio.Response()
230+
r.addReject(reason='busy')
231+
r = self.strip(r)
232+
self.assertEquals(r, '<Response><Reject reason="busy"/></Response>')
233+
234+
def testBadAppend(self):
235+
""" should raise exceptions for wrong appending"""
236+
self.improperAppend(twilio.Reject())
237+
216238
class TestSms(TwilioTest):
217239

218240
def testEmpty(self):

twilio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ def addRedirect(self, url=None, **kwargs):
216216
def addHangup(self, **kwargs):
217217
return self.append(Hangup(**kwargs))
218218

219+
def addReject(self, **kwargs):
220+
return self.append(Reject(**kwargs))
221+
219222
def addGather(self, **kwargs):
220223
return self.append(Gather(**kwargs))
221224

@@ -242,7 +245,7 @@ class Response(Verb):
242245
def __init__(self, version=None, **kwargs):
243246
Verb.__init__(self, version=version, **kwargs)
244247
self.nestables = ['Say', 'Play', 'Gather', 'Record', 'Dial',
245-
'Redirect', 'Pause', 'Hangup', 'Sms']
248+
'Redirect', 'Pause', 'Hangup', 'Reject', 'Sms']
246249

247250
class Say(Verb):
248251
"""Say text

0 commit comments

Comments
 (0)
0