def testRecordTranscribeCallback(self): """should record with a transcribe and transcribeCallback""" r = twilio.Response() r.append(twilio.Record(transcribeCallback="example.com")) r = self.strip(r) self.assertEquals( r, '<Response><Record transcribeCallback="example.com"/></Response>')
def testRecordActionMethod(self): """should record with an action and a get method""" r = twilio.Response() r.append(twilio.Record(action="example.com", method="GET")) r = self.strip(r) self.assertEquals( r, '<Response><Record action="example.com" method="GET"/></Response>')
def record(self, action=None, method=None, max_length=None, timeout=None, transcribe_callback=None, finish_on_key="1234567890*#"): if transcribe_callback: self.last_verb = twilio_official.Record(action, method, max_length, \ timeout, transcribeCallback=transcribe_callback, \ transcribe="true", finishOnKey=finish_on_key) else: self.last_verb = twilio_official.Record(action, method, max_length, \ timeout, finishOnKey=finish_on_key) self.twilio_response.append(self.last_verb) return self
def testRecordMaxlengthFinishTimeout(self): """should record with an maxlength, finishonkey, and timeout""" r = twilio.Response() r.append(twilio.Record(timeout=4, finishOnKey="#", maxLength=30)) r = self.strip(r) self.assertEquals( r, '<Response><Record finishOnKey="#" maxLength="30" timeout="4"/></Response>' )
def testImproperNesting(self): """ bad nesting""" verb = twilio.Gather() self.assertRaises(twilio.TwilioException, verb.append, twilio.Gather()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Record()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Hangup()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Redirect()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Dial()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Conference("")) self.assertRaises(twilio.TwilioException, verb.append, twilio.Sms(""))
def improperAppend(self, verb): self.assertRaises(twilio.TwilioException, verb.append, twilio.Say("")) self.assertRaises(twilio.TwilioException, verb.append, twilio.Gather()) 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.Redirect()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Dial()) self.assertRaises(twilio.TwilioException, verb.append, twilio.Conference("")) self.assertRaises(twilio.TwilioException, verb.append, twilio.Sms("")) self.assertRaises(twilio.TwilioException, verb.append, twilio.Pause())
def testPlayBadAppend(self): """ should raise exceptions for wrong appending""" self.improperAppend(twilio.Record())
def testPlayAddAttribute(self): """add attribute""" r = twilio.Record("", foo="bar") r = self.strip(r) self.assertEquals(r, '<Record foo="bar"/>')
def testRecordEmpty(self): """should record""" r = twilio.Response() r.append(twilio.Record()) r = self.strip(r) self.assertEquals(r, '<Response><Record/></Response>')