Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixing up Reject verb support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/twimltests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def improperAppend(self, verb):
self.assertRaises(twilio.TwilioException, verb.append, twilio.Play(""))
self.assertRaises(twilio.TwilioException, verb.append, twilio.Record())
self.assertRaises(twilio.TwilioException, verb.append, twilio.Hangup())
self.assertRaises(twilio.TwilioException, verb.append, twilio.Reject())
self.assertRaises(twilio.TwilioException, verb.append, twilio.Redirect())
self.assertRaises(twilio.TwilioException, verb.append, twilio.Dial())
self.assertRaises(twilio.TwilioException, verb.append, twilio.Conference(""))
Expand Down Expand Up @@ -213,6 +214,27 @@ def testBadAppend(self):
""" should raise exceptions for wrong appending"""
self.improperAppend(twilio.Hangup())


class TestReject(TwilioTest):

def testReject(self):
"""should be a Reject with default reason"""
r = twilio.Response()
r.append(twilio.Reject())
r = self.strip(r)
self.assertEquals(r, '<Response><Reject/></Response>')

def testRejectConvenience(self):
"""should be a Reject with reason Busy"""
r = twilio.Response()
r.addReject(reason='busy')
r = self.strip(r)
self.assertEquals(r, '<Response><Reject reason="busy"/></Response>')

def testBadAppend(self):
""" should raise exceptions for wrong appending"""
self.improperAppend(twilio.Reject())

class TestSms(TwilioTest):

def testEmpty(self):
Expand Down
5 changes: 4 additions & 1 deletion twilio.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def addRedirect(self, url=None, **kwargs):
def addHangup(self, **kwargs):
return self.append(Hangup(**kwargs))

def addReject(self, **kwargs):
return self.append(Reject(**kwargs))

def addGather(self, **kwargs):
return self.append(Gather(**kwargs))

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

class Say(Verb):
"""Say text
Expand Down