コード例 #1
0
ファイル: test.py プロジェクト: rsp2k/ciscotropowebapi
    def test_call(self):
        """
        Test the "call" Tropo class method.
        """

        tropo = Tropo()
        tropo.call(self.MY_PHONE, channel='TEXT', network='SMS')
        tropo.say("Wish you were here")
        rendered = tropo.RenderJson()
        pretty_rendered = tropo.RenderJson(pretty=True)
        print("============test_call=============")
        print("render json: %s" % pretty_rendered)

        rendered_obj = jsonlib.loads(rendered)
        wanted_json = '{"tropo": [{"call": {"to": "%s", "network": "SMS", "channel": "TEXT"}}, {"say": {"value": "Wish you were here"}}]}' % self.MY_PHONE
        wanted_obj = jsonlib.loads(wanted_json)
        # print "test_call: %s" % tropo.RenderJson()
        self.assertEqual(rendered_obj, wanted_obj)
コード例 #2
0
ファイル: test.py プロジェクト: rsp2k/ciscotropowebapi
if __name__ == '__main__':
    """
    Unit tests.
    """
    if (0):
        TO = "8005551212"

        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)
コード例 #3
0
def index(request):
    session = Session(request.body)
    t = Tropo()
    t.call(to=session.parameters['numberToDial'], network='JABBER')
    t.say(session.parameters['message'])
    return t.RenderJson()