Пример #1
0
 def test_add_empty_client(self):
     """ add an empty client to a dial """
     r = Response()
     d = r.dial()
     d.client("")
     assert_equal(
         str(r),
         '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client /></Dial></Response>'
     )
Пример #2
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)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record finishOnKey="#" maxLength="30" timeout="4" /></Response>'
     )
Пример #3
0
 def testConvience(self):
     """ should raises exceptions for wrong appending """
     r = Response()
     r.addSms("Hello")
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Sms>Hello</Sms></Response>'
     )
Пример #4
0
 def testConvienceMethod(self):
     """ should dial to a url via post """
     r = Response()
     r.addDial()
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Dial /></Response>'
     )
Пример #5
0
 def testReject(self):
     """ should be a Reject with default reason """
     r = Response()
     r.append(twiml.Reject())
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Reject /></Response>'
     )
Пример #6
0
 def testEmpty(self):
     """ Test empty sms verb """
     r = Response()
     r.append(twiml.Sms(""))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Sms /></Response>'
     )
Пример #7
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>'
     )
Пример #8
0
 def testHangupConvience(self):
     """ should raises exceptions for wrong appending """
     r = Response()
     r.addHangup()
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup /></Response>'
     )
Пример #9
0
    def test_context_manager(self):
        with Response() as r:
            with r.gather() as g:
                g.say("Hello")

            assert_equal(
                str(r),
                '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><Say>Hello</Say></Gather></Response>'
            )
Пример #10
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)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say language="en-gb">Hello Monkey</Say></Response>'
     )
Пример #11
0
 def testEmpty(self):
     """ a gather with nothing inside """
     r = Response()
     r.append(twiml.Gather())
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Gather /></Response>'
     )
Пример #12
0
 def test_add_client(self):
     """ add a client to a dial """
     r = Response()
     d = r.dial()
     d.client("alice")
     assert_equal(
         str(r),
         '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Client>alice</Client></Dial></Response>'
     )
Пример #13
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>'
     )
Пример #14
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>'
     )
Пример #15
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>'
     )
Пример #16
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>'
     )
Пример #17
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>'
     )
Пример #18
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>'
     )
Пример #19
0
 def testPlayConvienceMethod(self):
     """ convenience method: should play hello monkey """
     r = Response()
     r.addPlay("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>'
     )
Пример #20
0
 def testRejectConvenience(self):
     """ should be a Reject with reason Busy """
     r = Response()
     r.addReject(reason='busy')
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Reject reason="busy" /></Response>'
     )
Пример #21
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>'
     )
Пример #22
0
 def testBody(self):
     """ Test hello world """
     r = Response()
     r.append(twiml.Sms("Hello, World"))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Sms>Hello, World</Sms></Response>'
     )
Пример #23
0
 def testRecordEmpty(self):
     """ should record """
     r = Response()
     r.append(twiml.Record())
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record /></Response>'
     )
Пример #24
0
 def testDial(self):
     """ should redirect the call """
     r = Response()
     r.append(twiml.Dial("1231231234"))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Dial>1231231234</Dial></Response>'
     )
Пример #25
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)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record action="example.com" method="GET" /></Response>'
     )
Пример #26
0
 def testSayHelloWorld(self):
     """ should say hello monkey """
     r = Response()
     r.append(twiml.Say("Hello World"))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Say>Hello World</Say></Response>'
     )
Пример #27
0
 def testRecordTranscribeCallback(self):
     """ should record with a transcribe and transcribeCallback """
     r = Response()
     r.append(twiml.Record(transcribeCallback="example.com"))
     r = self.strip(r)
     assert_equal(
         r,
         '<?xml version="1.0" encoding="UTF-8"?><Response><Record transcribeCallback="example.com" /></Response>'
     )
Пример #28
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>')
Пример #29
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>')
Пример #30
0
    def setUp(self):
        r = Response()
        r.enqueue("TestEnqueueAttribute", action="act", method='GET',
                  waitUrl='wait', waitUrlMethod='POST')
        xml = r.toxml()

        #parse twiml XML string with Element Tree and inspect
        #structure
        tree = ET.fromstring(xml)
        self.conf = tree.find("./Enqueue")