Example #1
0
    def test_location(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser", "<location />")

        self.assertEquals(mock_console._response, "")
Example #2
0
    def test_text_only(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser", "Hello world")

        self.assertEquals(mock_console._response, "Hello world")
Example #3
0
    def test_split(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser", "<split />")

        self.assertEquals(mock_console._response, "<br />")
Example #4
0
    def test_delay(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser", "<delay><seconds>0</seconds></delay>")

        self.assertEquals(mock_console._response,
                          '<div class="delay">...</div>')
Example #5
0
    def test_image(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser",
                        "<image>http://servusai.com/aiml.png</image>")

        self.assertEquals(mock_console._response,
                          '<img src="http://servusai.com/aiml.png" />')
Example #6
0
    def test_olist(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser",
                        "<olist><item>Item1</item><item>Item2</item></olist>")

        self.assertEquals(mock_console._response,
                          "<ol><li>Item1</li><li>Item2</li></ol>")
Example #7
0
    def test_reply_without_postback(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser", "<reply><text>Hello</text></reply>")

        self.assertEquals(
            mock_console._response,
            '<a class="postback" postback="Hello" href="#">Hello</a>')
Example #8
0
    def test_link(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render(
            "testuser",
            "<link><text>Hello</text><url>http://click.me</url></link>")

        self.assertEquals(mock_console._response,
                          '<a href="http://click.me">Hello</a>')
Example #9
0
    def test_postback_button(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render(
            "testuser",
            "<button><text>Hello</text><postback>HELLO</postback></button>")

        self.assertEquals(
            mock_console._response,
            '<a class="postback" postback="HELLO" href="#">Hello</a>')
Example #10
0
    def test_carousel(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render(
            "testuser",
            "<carousel><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></carousel>"
        )

        self.assertEquals(
            mock_console._response,
            '<div class="carousel"><div class="card" ><img src="http://servusai.com/aiml.png" /><h1>Servusai</h1><h2>Home of ProgramR</h2><a href="http://click.me">Hello</a></div></div>'
        )
Example #11
0
    def test_video(self):
        mock_console = MockHtmlBotClient()
        renderer = HtmlRenderer(mock_console)
        self.assertIsNotNone(renderer)

        renderer.render("testuser",
                        "<video>http://servusai.com/aiml.mov</video>")

        self.assertEquals(
            mock_console._response,
            """<video src="http://servusai.com/aiml.mov">
Sorry, your browser doesn't support embedded videos, 
but don't worry, you can <a href="http://servusai.com/aiml.mov">download it</a>
and watch it with your favorite video player!
</video>""")