コード例 #1
0
 def testAddNumberConvience(self):
     """add a number to a dial, convience method"""
     r = Response()
     d = r.addDial()
     d.addNumber("1231231234")
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial><Number>1231231234</Number></Dial></Response>')
コード例 #2
0
 def testAddConferenceConvenceMethod(self):
     """ add a conference to a dial, conviently"""
     r = Response()
     d = r.addDial()
     d.addConference("My Room")
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial><Conference>My Room</Conference></Dial></Response>')
コード例 #3
0
 def testToFromAction(self):
     """ Test the to, from, and status callback"""
     r = Response()
     r.append(telml.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>')
コード例 #4
0
 def testAddConference(self):
     """ add a conference to a dial"""
     r = Response()
     d = telml.Dial()
     d.append(telml.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>')
コード例 #5
0
 def testAddNumber(self):
     """add a number to a dial"""
     r = Response()
     d = telml.Dial()
     d.append(telml.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>')
コード例 #6
0
 def testNestedSayPlayPauseConvience(self):
     """ a gather with a say, play, and pause"""
     r = Response()
     g = r.addGather()
     g.addSay("Hey")
     g.addPlay("hey.mp3")
     g.addPause()
     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>')
コード例 #7
0
 def testNestedSayPlayPause(self):
     """ a gather with a say, play, and pause"""
     r = Response()
     g = telml.Gather()
     g.append(telml.Say("Hey"))
     g.append(telml.Play("hey.mp3"))
     g.append(telml.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>')
コード例 #8
0
 def testRecordMaxlengthFinishTimeout(self):
     """should record with an maxlength, finishonkey, and timeout"""
     r = Response()
     r.addRecord(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>')
コード例 #9
0
 def testEmpty(self):
     """ a gather with nothing inside"""
     r = Response()
     r.append(telml.Gather())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Gather /></Response>')
コード例 #10
0
 def testRedirectMethodGetParams(self):
     r = Response()
     r.append(telml.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>')
コード例 #11
0
 def testRedirectEmpty(self):
     r = Response()
     r.append(telml.Redirect())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Redirect /></Response>')
コード例 #12
0
 def testRecordTranscribeCallback(self):
     """should record with a transcribe and transcribeCallback"""
     r = Response()
     r.append(telml.Record(transcribeCallback="example.com"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Record transcribeCallback="example.com" /></Response>')
コード例 #13
0
 def testHangup(self):
     """convenience: should Hangup to a url via POST"""
     r = Response()
     r.append(telml.Hangup())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Hangup /></Response>')
コード例 #14
0
 def testSayLoopWoman(self):
     """should say have a woman say hello monkey and loop 3 times"""
     r = Response()
     r.append(telml.Say("Hello Monkey", loop=3, voice=telml.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>')
コード例 #15
0
 def testEmptyPlay(self):
     """should play hello monkey"""
     r = Response()
     r.append(telml.Play(""))
     r = self.strip(r)
     self.assertEqual(r,'<?xml version="1.0" encoding="utf-8"?><Response><Play /></Response>')
コード例 #16
0
 def testEmptySay(self):
     """should be a say with no text"""
     r = Response()
     r.append(telml.Say(""))
     self.assertEquals(self.strip(r), '<?xml version="1.0" encoding="utf-8"?><Response><Say /></Response>')
コード例 #17
0
 def testSayHelloWorld(self):
     """should say hello monkey"""
     r = Response()
     r.append(telml.Say("Hello World"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Say>Hello World</Say></Response>')
コード例 #18
0
 def testBody(self):
     """Test hello world"""
     r = Response()
     r.append(telml.Sms("Hello, World"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms>Hello, World</Sms></Response>')
コード例 #19
0
 def testEmpty(self):
     """Test empty sms verb"""
     r = Response()
     r.append(telml.Sms(""))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms /></Response>')
コード例 #20
0
 def testRejectConvenience(self):
     """should be a Reject with reason Busy"""
     r = Response()
     r.addReject(reason='busy')
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Reject reason="busy" /></Response>')
コード例 #21
0
 def testReject(self):
     """should be a Reject with default reason"""
     r = Response()
     r.append(telml.Reject())
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Reject /></Response>')
コード例 #22
0
 def testHangupConvience(self):
     """should raises exceptions for wrong appending"""
     r = Response()
     r.addHangup()
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Hangup /></Response>')
コード例 #23
0
 def testActionMethod(self):
     """ Test the action and method parameters on Sms"""
     r = Response()
     r.append(telml.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>')
コード例 #24
0
 def testConvience(self):
     """should raises exceptions for wrong appending"""
     r = Response()
     r.addSms("Hello")
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Sms>Hello</Sms></Response>')
コード例 #25
0
 def testSayFrench(self):
     """should say hello monkey"""
     r = Response()
     r.append(telml.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>')
コード例 #26
0
 def testDial(self):
     """ should redirect the call"""
     r = Response()
     r.append(telml.Dial("1231231234"))
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial>1231231234</Dial></Response>')
コード例 #27
0
 def testSayConvienceMethod(self):
     """convenience method: should say have a woman say hello monkey and loop 3 times and be in french"""
     r = Response()
     r.addSay("Hello Monkey", loop=3, voice=telml.Say.MAN, language=telml.Say.FRENCH)
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Say language="fr" loop="3" voice="man">Hello Monkey</Say></Response>')
コード例 #28
0
 def testConvienceMethod(self):
     """ should dial to a url via post"""
     r = Response()
     r.addDial()
     r = self.strip(r)
     self.assertEquals(r, '<?xml version="1.0" encoding="utf-8"?><Response><Dial /></Response>')
コード例 #29
0
 def testPlayHello(self):
     """should play hello monkey"""
     r = Response()
     r.append(telml.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>')
コード例 #30
0
 def testRecordActionMethod(self):
     """should record with an action and a get method"""
     r = Response()
     r.append(telml.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>')