示例#1
0
    def test_record(self):
        """
        Test the "record" Tropo class method.
        """

        tropo = Tropo()
        url = "/receive_recording.py"
        choices_obj = Choices("", terminator="#").json
        tropo.record(say="Tell us about yourself",
                     url=url,
                     choices=choices_obj)
        rendered = tropo.RenderJson()
        pretty_rendered = tropo.RenderJson(pretty=True)
        print("===============test_record=================")
        print("render json: %s" % pretty_rendered)

        # print "test_record: %s" % tropo.RenderJson()
        rendered_obj = jsonlib.loads(rendered)
        wanted_json = ' {"tropo": [{"record": {"url": "/receive_recording.py", "say": {"value": "Tell us about yourself"}, "choices": {"terminator": "#", "value": ""}}}]}'
        wanted_obj = jsonlib.loads(wanted_json)
        self.assertEqual(rendered_obj, wanted_obj)
示例#2
0
        ID = "foo"
        URL = "http://s3.amazonaws.com/xxx_s3_bucket/hello.wav"

        tropo = Tropo()

        tropo.ask("[5 digits]",
                  say=Say("Please enter a 5 digit zip code").json)

        tropo.call(TO)
        tropo.conference(ID)
        tropo.hangup()
        tropo.message("Hello, World", TO)
        tropo.on(event="continue",
                 next="http://example.com/weather.py",
                 say="Please hold.")

        tropo.record(say="Please say something for posterity",
                     url=URL,
                     choices=Choices("", terminator="#").json)
        tropo.redirect(ID)
        tropo.reject(ID)
        tropo.startRecording(URL)
        tropo.stopRecording()
        tropo.transfer(TO)

        tropo.message("Hello, World", TO, channel='TEXT', network='SMS')

    else:
        unittest.main()