Exemplo n.º 1
0
 def testPlayHello(self):
     """should play hello monkey"""
     r = twilio.Response()
     r.append(twilio.Play("http://hellomonkey.mp3"))
     r = self.strip(r)
     self.assertEqual(
         r, "<Response><Play>http://hellomonkey.mp3</Play></Response>")
Exemplo n.º 2
0
 def testPlayHelloLoop(self):
     """should play hello monkey loop"""
     r = twilio.Response()
     r.append(twilio.Play("http://hellomonkey.mp3", loop=3))
     r = self.strip(r)
     self.assertEqual(
         r,
         '<Response><Play loop="3">http://hellomonkey.mp3</Play></Response>'
     )
Exemplo n.º 3
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())
Exemplo n.º 4
0
 def testNestedSayPlayPause(self):
     """ a gather with a say, play, and pause"""
     r = twilio.Response()
     g = twilio.Gather()
     g.append(twilio.Say("Hey"))
     g.append(twilio.Play("hey.mp3"))
     g.append(twilio.Pause())
     r.append(g)
     r = self.strip(r)
     self.assertEquals(
         r,
         '<Response><Gather><Say>Hey</Say><Play>hey.mp3</Play><Pause/></Gather></Response>'
     )
Exemplo n.º 5
0
    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,
         loop=10)
Exemplo n.º 6
0
 def testEmptyPlay(self):
     """should play hello monkey"""
     r = twilio.Response()
     r.append(twilio.Play(""))
     r = self.strip(r)
     self.assertEqual(r, "<Response><Play/></Response>")
Exemplo n.º 7
0
 def testPlayBadAppend(self):
     """ should raise exceptions for wrong appending"""
     self.improperAppend(twilio.Play(""))
Exemplo n.º 8
0
 def testPlayAddAttribute(self):
     """add attribute"""
     r = twilio.Play("", foo="bar")
     r = self.strip(r)
     self.assertEquals(r, '<Play foo="bar"/>')
Exemplo n.º 9
0
    def play(self, to_play, loop=0):
        self.last_verb = twilio_official.Play(to_play, loop)
        self.twilio_response.append(self.last_verb)

        return self