Ejemplo n.º 1
0
 def testRedirectMethod(self):
     r = twilio.Response()
     r.append(twilio.Redirect(url="example.com", method="POST"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<Response><Redirect method="POST">example.com</Redirect></Response>'
     )
Ejemplo n.º 2
0
 def testRedirectMethodGetParams(self):
     r = twilio.Response()
     r.append(
         twilio.Redirect(url="example.com?id=34&action=hey", method="POST"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<Response><Redirect method="POST">example.com?id=34&amp;action=hey</Redirect></Response>'
     )
Ejemplo n.º 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(""))
Ejemplo n.º 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())
Ejemplo n.º 5
0
# 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)
r.addDial("4155551212", timeLimit=45)
r.addPlay("http://www.mp3.com")
print r

# ===========================================================================
# Using Gather, Redirect
r = twilio.Response()
g = r.append(twilio.Gather(numDigits=1))
g.append(twilio.Say("Press 1"))
r.append(twilio.Redirect())
print r
""" outputs:
<Response>
    <Gather numDigits="1">
        <Say>Press 1</Say>
    </Gather>
    <Redirect/>
</Response>
"""

# ===========================================================================
# Adding a Say verb multiple times
r = twilio.Response()
s = twilio.Say("Press 1")
r.append(s)
Ejemplo n.º 6
0
 def testBadAppend(self):
     """ should raise exceptions for wrong appending"""
     self.improperAppend(twilio.Redirect())
Ejemplo n.º 7
0
 def testAddAttribute(self):
     """add attribute"""
     r = twilio.Redirect("", foo="bar")
     r = self.strip(r)
     self.assertEquals(r, '<Redirect foo="bar"/>')
Ejemplo n.º 8
0
 def testRedirectEmpty(self):
     r = twilio.Response()
     r.append(twilio.Redirect())
     r = self.strip(r)
     self.assertEquals(r, '<Response><Redirect/></Response>')
Ejemplo n.º 9
0
    def redirect(self, url, method=HTTP_METHOD_GET):
        self.last_verb = twilio_official.Redirect(url, method)
        self.twilio_response.append(self.last_verb)

        return self