Example #1
0
 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>')
Example #2
0
 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>')
Example #3
0
    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
Example #4
0
 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>'
     )
Example #5
0
 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(""))
Example #6
0
 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())
Example #7
0
 def testPlayBadAppend(self):
     """ should raise exceptions for wrong appending"""
     self.improperAppend(twilio.Record())
Example #8
0
 def testPlayAddAttribute(self):
     """add attribute"""
     r = twilio.Record("", foo="bar")
     r = self.strip(r)
     self.assertEquals(r, '<Record foo="bar"/>')
Example #9
0
 def testRecordEmpty(self):
     """should record"""
     r = twilio.Response()
     r.append(twilio.Record())
     r = self.strip(r)
     self.assertEquals(r, '<Response><Record/></Response>')