示例#1
0
 def testAddNumber(self):
     """add a number to a dial"""
     r = twilio.Response()
     d = twilio.Dial()
     d.append(twilio.Number("1231231234"))
     r.append(d)
     r = self.strip(r)
     self.assertEquals(
         r, '<Response><Dial><Number>1231231234</Number></Dial></Response>')
示例#2
0
 def testAddConference(self):
     """ add a conference to a dial"""
     r = twilio.Response()
     d = twilio.Dial()
     d.append(twilio.Conference("My Room"))
     r.append(d)
     r = self.strip(r)
     self.assertEquals(
         r,
         '<Response><Dial><Conference>My Room</Conference></Dial></Response>'
     )
示例#3
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(""))
示例#4
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())
示例#5
0
    Number
    Conference
    Sms
"""

import twilio

# ===========================================================================
# Using Say, Dial, and Play
r = twilio.Response()
r.append(
    twilio.Say("Hello World",
               voice=twilio.Say.MAN,
               language=twilio.Say.FRENCH,
               loop=10))
r.append(twilio.Dial("4155551212", timeLimit=45))
r.append(twilio.Play("http://www.mp3.com"))
print r
""" outputs:
<Response>
    <Say voice="man" language="fr" loop="10">Hello World</Say>
    <Dial timeLimit="45">4155551212</Dial>
    <Play>http://www.mp3.com</Play>
</Response>
"""

# The same XML can be created above using the convenience methods
r = twilio.Response()
r.addSay("Hello World",
         voice=twilio.Say.MAN,
         language=twilio.Say.FRENCH,
示例#6
0
 def testDial(self):
     """ should redirect the call"""
     r = twilio.Response()
     r.append(twilio.Dial("1231231234"))
     r = self.strip(r)
     self.assertEquals(r, '<Response><Dial>1231231234</Dial></Response>')
示例#7
0
    def dial(self, number, action=None, method=None):
        self.last_verb = twilio_official.Dial(number, action, method)
        self.twilio_response.append(self.last_verb)

        return self