예제 #1
0
 def testToFromAction(self):
     """ Test the to, from, and status callback """
     r = Response()
     r.append(twiml.Sms("Hello, World", to=1231231234, sender=3453453456,
         statusCallback="example.com?id=34&action=hey"))
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Sms from="3453453456" statusCallback="example.com?id=34&amp;action=hey" to="1231231234">Hello, World</Sms></Response>')
예제 #2
0
 def testToFromAction(self):
     """ Test the to, from, and status callback"""
     r = Response()
     r.append(twiml.Sms("Hello, World", to=1231231234, sender=3453453456,
         statusCallback="example.com?id=34&action=hey"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms from="3453453456" statusCallback="example.com?id=34&amp;action=hey" to="1231231234">Hello, World</Sms></Response>')
예제 #3
0
 def testAddNumber(self):
     """ add a number to a dial """
     r = Response()
     d = twiml.Dial()
     d.append(twiml.Number("1231231234"))
     r.append(d)
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number>1231231234</Number></Dial></Response>')
예제 #4
0
 def testSayFrench(self):
     """should say hello monkey"""
     r = Response()
     r.append(twiml.Say(u"nécessaire et d'autres"))
     self.assertEquals(
         unicode(r),
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say>n&#233;cessaire et d\'autres</Say></Response>'
     )
예제 #5
0
 def testAddNumberStatusCallbackEvent(self):
     """ add a number to a dial with status callback events"""
     r = Response()
     d = twiml.Dial()
     d.append(twiml.Number("1231231234", statusCallback="http://example.com", statusCallbackEvent="initiated completed"))
     r.append(d)
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number statusCallback="http://example.com" statusCallbackEvent="initiated completed">1231231234</Number></Dial></Response>')
예제 #6
0
 def testAddConference(self):
     """ add a conference to a dial """
     r = Response()
     d = twiml.Dial()
     d.append(twiml.Conference("My Room"))
     r.append(d)
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>')
예제 #7
0
 def testAddNumber(self):
     """add a number to a dial"""
     r = Response()
     d = twiml.Dial()
     d.append(twiml.Number("1231231234"))
     r.append(d)
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial><Number>1231231234</Number></Dial></Response>')
예제 #8
0
 def testRedirectMethod(self):
     r = Response()
     r.append(twiml.Redirect(url="example.com", method="POST"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect method="POST">example.com</Redirect></Response>'
     )
예제 #9
0
 def testEmptySay(self):
     """should be a say with no text"""
     r = Response()
     r.append(twiml.Say(""))
     self.assertEquals(
         self.strip(r),
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say /></Response>'
     )
예제 #10
0
 def testAddConference(self):
     """ add a conference to a dial"""
     r = Response()
     d = twiml.Dial()
     d.append(twiml.Conference("My Room"))
     r.append(d)
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>')
예제 #11
0
 def testRedirectEmpty(self):
     r = Response()
     r.append(twiml.Redirect())
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect /></Response>'
     )
예제 #12
0
 def testDial(self):
     """ should redirect the call"""
     r = Response()
     r.append(twiml.Dial("1231231234"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Dial>1231231234</Dial></Response>'
     )
예제 #13
0
 def testPlayHelloLoop(self):
     """should play hello monkey loop"""
     r = Response()
     r.append(twiml.Play("http://hellomonkey.mp3", loop=3))
     r = self.strip(r)
     self.assertEqual(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Play loop="3">http://hellomonkey.mp3</Play></Response>'
     )
예제 #14
0
 def testSayLoopWoman(self):
     """ should say have a woman say hello monkey and loop 3 times """
     r = Response()
     r.append(twiml.Say("Hello Monkey", loop=3, voice=twiml.Say.WOMAN))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say loop="3" voice="woman">Hello Monkey</Say></Response>'
     )
예제 #15
0
 def testEmpty(self):
     """Test empty sms verb"""
     r = Response()
     r.append(twiml.Sms(""))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Sms /></Response>'
     )
예제 #16
0
 def testSayLoopGreatBritian(self):
     """should say have a woman say hello monkey and loop 3 times"""
     r = Response()
     r.append(twiml.Say("Hello Monkey", language="en-gb"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say language="en-gb">Hello Monkey</Say></Response>'
     )
예제 #17
0
 def testRecordTranscribeCallback(self):
     """should record with a transcribe and transcribeCallback"""
     r = Response()
     r.append(twiml.Record(transcribeCallback="example.com"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record transcribeCallback="example.com" /></Response>'
     )
예제 #18
0
 def testRecordMaxlengthFinishTimeout(self):
     """should record with an maxlength, finishonkey, and timeout"""
     r = Response()
     r.append(twiml.Record(timeout=4, finishOnKey="#", maxLength=30))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record finishOnKey="#" maxLength="30" timeout="4" /></Response>'
     )
예제 #19
0
 def testRecordActionMethod(self):
     """should record with an action and a get method"""
     r = Response()
     r.append(twiml.Record(action="example.com", method="GET"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record action="example.com" method="GET" /></Response>'
     )
예제 #20
0
 def testRecordEmpty(self):
     """should record"""
     r = Response()
     r.append(twiml.Record())
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record /></Response>'
     )
예제 #21
0
 def testSayHelloWorld(self):
     """should say hello monkey"""
     r = Response()
     r.append(twiml.Say("Hello World"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say>Hello World</Say></Response>'
     )
예제 #22
0
 def testLeave(self):
     """convenience: should Hangup to a url via POST"""
     r = Response()
     r.append(twiml.Leave())
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Leave /></Response>'
     )
예제 #23
0
 def testEmpty(self):
     """ a gather with nothing inside"""
     r = Response()
     r.append(twiml.Gather())
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Gather /></Response>'
     )
예제 #24
0
 def testReject(self):
     """should be a Reject with default reason"""
     r = Response()
     r.append(twiml.Reject())
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Reject /></Response>'
     )
예제 #25
0
 def testSayLoop(self):
     """should say hello monkey and loop 3 times"""
     r = Response()
     r.append(twiml.Say("Hello Monkey", loop=3))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say loop="3">Hello Monkey</Say></Response>'
     )
예제 #26
0
 def testRedirectMethodGetParams(self):
     r = Response()
     r.append(
         twiml.Redirect(url="example.com?id=34&action=hey", method="POST"))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect method="POST">example.com?id=34&amp;action=hey</Redirect></Response>'
     )
예제 #27
0
 def testBody(self):
     """Test hello world"""
     r = Response()
     r.append(twiml.Sms("Hello, World"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Sms>Hello, World</Sms></Response>'
     )
예제 #28
0
 def testEmptyPlay(self):
     """should play hello monkey"""
     r = Response()
     r.append(twiml.Play(""))
     r = self.strip(r)
     self.assertEqual(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Play /></Response>'
     )
예제 #29
0
 def testPlayDigits(self):
     """ should play digits """
     r = Response()
     r.append(twiml.Play(digits='w123'))
     r = self.strip(r)
     self.assertEqual(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Play digits="w123" /></Response>'
     )
예제 #30
0
 def testHangup(self):
     """ convenience: should Hangup to a url via POST """
     r = Response()
     r.append(twiml.Hangup())
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup /></Response>'
     )
예제 #31
0
 def testSayFrench(self):
     """should say hello monkey"""
     r = Response()
     r.append(
         twiml.Say(u("n\xe9cessaire et d'autres"))
     )  # it works on python 2.6 with the from __future__ import unicode_literal
     self.assertEquals(
         text_type(r),
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say>n&#233;cessaire et d\'autres</Say></Response>'
     )
예제 #32
0
 def testNestedSayPlayPause(self):
     """ a gather with a say, play, and pause"""
     r = Response()
     g = twiml.Gather()
     g.append(twiml.Say("Hey"))
     g.append(twiml.Play("hey.mp3"))
     g.append(twiml.Pause())
     r.append(g)
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Gather><Say>Hey</Say><Play>hey.mp3</Play><Pause /></Gather></Response>')
예제 #33
0
 def testNestedSayPlayPause(self):
     """ a gather with a say, play, and pause """
     r = Response()
     g = twiml.Gather()
     g.append(twiml.Say("Hey"))
     g.append(twiml.Play("hey.mp3"))
     g.append(twiml.Pause())
     r.append(g)
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><Say>Hey</Say><Play>hey.mp3</Play><Pause /></Gather></Response>')
예제 #34
0
 def testActionMethod(self):
     """ Test the action and method parameters on Sms"""
     r = Response()
     r.append(
         twiml.Sms("Hello",
                   method="POST",
                   action="example.com?id=34&action=hey"))
     r = self.strip(r)
     self.assertEquals(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Sms action="example.com?id=34&amp;action=hey" method="POST">Hello</Sms></Response>'
     )
예제 #35
0
 def testAddNumberStatusCallbackEvent(self):
     """ add a number to a dial with status callback events"""
     r = Response()
     d = twiml.Dial()
     d.append(
         twiml.Number("1231231234",
                      statusCallback="http://example.com",
                      statusCallbackEvent="initiated completed"))
     r.append(d)
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number statusCallback="http://example.com" statusCallbackEvent="initiated completed">1231231234</Number></Dial></Response>'
     )
예제 #36
0
 def testActionMethod(self):
     """ Test the action and method parameters on Sms"""
     r = Response()
     r.append(twiml.Sms("Hello", method="POST", action="example.com?id=34&action=hey"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms action="example.com?id=34&amp;action=hey" method="POST">Hello</Sms></Response>')
예제 #37
0
 def testDial(self):
     """ should redirect the call"""
     r = Response()
     r.append(twiml.Dial("1231231234"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial>1231231234</Dial></Response>')
예제 #38
0
 def testEmptyPlay(self):
     """should play hello monkey"""
     r = Response()
     r.append(twiml.Play(""))
     r = self.strip(r)
     self.assertEqual(r,'<?xml version="1.0" encoding="utf-8"?><Response><Play /></Response>')
예제 #39
0
 def testSayLoopGreatBritian(self):
     """should say have a woman say hello monkey and loop 3 times"""
     r = Response()
     r.append(twiml.Say("Hello Monkey", language="en-gb"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Say language="en-gb">Hello Monkey</Say></Response>')
예제 #40
0
 def testEmptySay(self):
     """should be a say with no text"""
     r = Response()
     r.append(twiml.Say(""))
     self.assertEquals(self.strip(r), '<?xml version="1.0" encoding="utf-8"?><Response><Say /></Response>')
예제 #41
0
 def testSayFrench(self):
     """should say hello monkey"""
     r = Response()
     r.append(twiml.Say(u"nécessaire et d'autres"))
     self.assertEquals(unicode(r),
                       '<?xml version="1.0" encoding="utf-8"?><Response><Say>n&#233;cessaire et d\'autres</Say></Response>')
예제 #42
0
 def testRedirectMethodGetParams(self):
     r = Response()
     r.append(twiml.Redirect(url="example.com?id=34&action=hey", method="POST"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Redirect method="POST">example.com?id=34&amp;action=hey</Redirect></Response>')
예제 #43
0
 def testEmpty(self):
     """ a gather with nothing inside"""
     r = Response()
     r.append(twiml.Gather())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Gather /></Response>')
예제 #44
0
 def testRecordTranscribeCallback(self):
     """should record with a transcribe and transcribeCallback"""
     r = Response()
     r.append(twiml.Record(transcribeCallback="example.com"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Record transcribeCallback="example.com" /></Response>')
예제 #45
0
 def testRedirectEmpty(self):
     r = Response()
     r.append(twiml.Redirect())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Redirect /></Response>')
예제 #46
0
 def testRecordMaxlengthFinishTimeout(self):
     """should record with an maxlength, finishonkey, and timeout"""
     r = Response()
     r.append(twiml.Record(timeout=4,finishOnKey="#", maxLength=30))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Record finishOnKey="#" maxLength="30" timeout="4" /></Response>')
예제 #47
0
 def testRecordActionMethod(self):
     """should record with an action and a get method"""
     r = Response()
     r.append(twiml.Record(action="example.com", method="GET"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Record action="example.com" method="GET" /></Response>')
예제 #48
0
 def testRecordEmpty(self):
     """should record"""
     r = Response()
     r.append(twiml.Record())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Record /></Response>')
예제 #49
0
 def testSayFrench(self):
     """ should say hello monkey """
     r = Response()
     r.append(twiml.Say(u("n\xe9cessaire et d'autres")))  # it works on python 2.6 with the from __future__ import unicode_literal
     assert_equal(text_type(r),
                  '<?xml version="1.0" encoding="UTF-8"?><Response><Say>n&#233;cessaire et d\'autres</Say></Response>')
예제 #50
0
 def testHangup(self):
     """convenience: should Hangup to a url via POST"""
     r = Response()
     r.append(twiml.Hangup())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Hangup /></Response>')
예제 #51
0
 def testLeave(self):
     """ convenience: should Hangup to a url via POST """
     r = Response()
     r.append(twiml.Leave())
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Leave /></Response>')
예제 #52
0
 def testReject(self):
     """should be a Reject with default reason"""
     r = Response()
     r.append(twiml.Reject())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Reject /></Response>')
예제 #53
0
 def testPlayDigits(self):
     """ should play digits """
     r = Response()
     r.append(twiml.Play(digits='w123'))
     r = self.strip(r)
     self.assertEqual(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Play digits="w123" /></Response>')
예제 #54
0
 def testEmpty(self):
     """Test empty sms verb"""
     r = Response()
     r.append(twiml.Sms(""))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms /></Response>')
예제 #55
0
 def testSayHelloWorld(self):
     """should say hello monkey"""
     r = Response()
     r.append(twiml.Say("Hello World"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Say>Hello World</Say></Response>')
예제 #56
0
 def testBody(self):
     """Test hello world"""
     r = Response()
     r.append(twiml.Sms("Hello, World"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms>Hello, World</Sms></Response>')
예제 #57
0
 def testSayLoopWoman(self):
     """should say have a woman say hello monkey and loop 3 times"""
     r = Response()
     r.append(twiml.Say("Hello Monkey", loop=3, voice=twiml.Say.WOMAN))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Say loop="3" voice="woman">Hello Monkey</Say></Response>')
예제 #58
0
 def testRedirectMethod(self):
     r = Response()
     r.append(twiml.Redirect(url="example.com", method="POST"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect method="POST">example.com</Redirect></Response>')
예제 #59
0
 def testPlayHello(self):
     """should play hello monkey"""
     r = Response()
     r.append(twiml.Play("http://hellomonkey.mp3"))
     r = self.strip(r)
     self.assertEqual(r, '<?xml version="1.0" encoding="utf-8"?><Response><Play>http://hellomonkey.mp3</Play></Response>')
예제 #60
0
 def testSayLoop(self):
     """should say hello monkey and loop 3 times"""
     r = Response()
     r.append(twiml.Say("Hello Monkey", loop=3))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Say loop="3">Hello Monkey</Say></Response>')