def test_image(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<image>http://servusai.com/aiml.png</image>") self.assertEquals(mock_console._response, "To see the image, click http://servusai.com/aiml.png")
def test_video(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<video>http://servusai.com/aiml.mov</video>") self.assertEquals(mock_console._response, "To see the video, click http://servusai.com/aiml.mov")
def test_postback_button(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<button><text>Hello</text><postback>HELLO</postback></button>") self.assertEquals(mock_console._response, "HELLO")
def test_link(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<link><text>Hello</text><url>http://click.me</url></link>") self.assertEquals(mock_console._response, "Open in browser, click http://click.me")
def test_text_only(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "Hello world") self.assertEquals(mock_console._response, "Hello world")
def test_url_button(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<button><text>Hello</text><url>http://click.me</url></button>") self.assertEquals(mock_console._response, "Hello, click http://click.me")
def test_location(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<location />") self.assertEquals(mock_console._response, "")
def test_olist(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<olist><item>Item1</item><item>Item2</item></olist>") self.assertEquals(mock_console._response, "1. Item1\n2. Item2\n")
def test_split(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<split />") self.assertEquals(mock_console._response, "\n")
def test_delay(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<delay><seconds>0</seconds></delay>") self.assertEquals(mock_console._response, "...")
def test_reply_without_postback(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<reply><text>Hello</text></reply>") self.assertEquals(mock_console._response, "Hello")
def test_card(self): mock_console = MockConsoleBotClient() renderer = TextRenderer(mock_console) self.assertIsNotNone(renderer) renderer.render("testuser", "<card><image>http://servusai.com/aiml.png</image><title>Servusai</title><subtitle>Home of ProgramR</subtitle><button><text>Hello</text><url>http://click.me</url></button></card>") self.assertEquals(mock_console._response, """Image: http://servusai.com/aiml.png Title: Servusai Subtitle: Home of ProgramR --------------------------------------- Hello : http://click.me --------------------------------------- """)
def __init__(self, callback=None): TextRenderer.__init__(self, callback)
def get_default_renderer(self): return TextRenderer(self)