diff --git a/tests/twimltests.py b/tests/twimltests.py index bb98608049..b608bd2efa 100644 --- a/tests/twimltests.py +++ b/tests/twimltests.py @@ -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("")) @@ -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, '') + + def testRejectConvenience(self): + """should be a Reject with reason Busy""" + r = twilio.Response() + r.addReject(reason='busy') + r = self.strip(r) + self.assertEquals(r, '') + + def testBadAppend(self): + """ should raise exceptions for wrong appending""" + self.improperAppend(twilio.Reject()) + class TestSms(TwilioTest): def testEmpty(self): diff --git a/twilio.py b/twilio.py index bcbb7aa12a..da0f10d268 100755 --- a/twilio.py +++ b/twilio.py @@ -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)) @@ -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