def test_list_say(self): """ Test the "say" Tropo class method, when a list of Strings is passed to it. """ tropo = Tropo() tropo.say(["Hello, World", "How ya doing?"]) rendered = tropo.RenderJson() pretty_rendered = tropo.RenderJson(pretty=True) print("===============test_list_say=================") print("render json: %s" % pretty_rendered) # print "test_say: %s" % tropo.RenderJson() rendered_obj = jsonlib.loads(rendered) wanted_json = '{"tropo": [{"say": [{"value": "Hello, World"}, {"value": "How ya doing?"}]}]}' wanted_obj = jsonlib.loads(wanted_json) self.assertEqual(rendered_obj, wanted_obj)
def test_say(self): """ Test the "say" Tropo class method. """ tropo = Tropo() tropo.say("Hello, World") rendered = tropo.RenderJson() pretty_rendered = tropo.RenderJson(pretty=True) print("===============test_say=================") print("render json: %s" % pretty_rendered) # print "test_say: %s" % tropo.RenderJson() rendered_obj = jsonlib.loads(rendered) wanted_json = '{"tropo": [{"say": {"value": "Hello, World"}}]}' wanted_obj = jsonlib.loads(wanted_json) self.assertEqual(rendered_obj, wanted_obj)
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)
def test_transfer(self): """ Test the "transfer" Tropo class method. """ tropo = Tropo() tropo.say("One moment please.") tropo.transfer(self.MY_PHONE) tropo.say("Hi. I am a robot") rendered = tropo.RenderJson() pretty_rendered = tropo.RenderJson(pretty=True) print("===============test_transfer=================") print("render json: %s" % pretty_rendered) # print "test_transfer: %s" % tropo.RenderJson() rendered_obj = jsonlib.loads(rendered) wanted_json = '{"tropo": [{"say": {"value": "One moment please."}}, {"transfer": {"to": "6021234567"}}, {"say": {"value": "Hi. I am a robot"}}]}' wanted_obj = jsonlib.loads(wanted_json) self.assertEqual(rendered_obj, wanted_obj)
def index(request): s = Session(request.body) t = Tropo() t.say(['hello workd!', 'how are you doing?']) return t.RenderJson()
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()