def test_carousel_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) carousel = TemplateCarouselNode() card = TemplateCardNode() card._image = TemplateWordNode("http://Servusai.com") card._title = TemplateWordNode("Servusai.com") card._subtitle = TemplateWordNode("The home of ProgramY") button = TemplateButtonNode() button._text = TemplateWordNode("More...") button._url = TemplateWordNode("http://Servusai.com/aiml") card._buttons.append(button) carousel._cards.append(card) root.append(carousel) resolved = root.resolve(self._client_context) self.assertIsNotNone(resolved) self.assertEqual( "<carousel><card><title>Servusai.com</title><subtitle>The home of ProgramY</subtitle><image>http://Servusai.com</image><button><text>More...</text><url>http://Servusai.com/aiml</url></button></card></carousel>", resolved) xml = root.to_xml(self._client_context) self.assertIsNotNone(xml) self.assertEqual( "<carousel><card><title>Servusai.com</title><subtitle>The home of ProgramY</subtitle><image>http://Servusai.com</image><button><text>More...</text><url>http://Servusai.com/aiml</url></button></card></carousel>", xml)
def test_carousel_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) carousel = TemplateCarouselNode() card = TemplateCardNode() card._image = TemplateWordNode("http://Servusai.com") card._title = TemplateWordNode("Servusai.com") card._subtitle = TemplateWordNode("The home of ProgramY") button = TemplateButtonNode() button._text = TemplateWordNode("More...") button._url = TemplateWordNode("http://Servusai.com/aiml") card._buttons.append(button) carousel._cards.append(card) root.append(carousel) resolved = root.resolve(self._client_context) self.assertIsNotNone(resolved) self.assertEquals("<carousel><card><image>http://Servusai.com</image><title>Servusai.com</title><subtitle>The home of ProgramY</subtitle><button><text>More...</text><url>http://Servusai.com/aiml</url></button></card></carousel>", resolved) self.assertEquals("<carousel><card><image>http://Servusai.com</image><title>Servusai.com</title><subtitle>The home of ProgramY</subtitle><button><text>More...</text><url>http://Servusai.com/aiml</url></button></card></carousel>", root.to_xml(self._client_context))
def test_url_postback_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) button = TemplateButtonNode() button._text = TemplateWordNode("SAY HELLO") button._postback = TemplateWordNode("HELLO") root.append(button) resolved = root.resolve(self._client_context) self.assertIsNotNone(resolved) self.assertEquals("<button><text>SAY HELLO</text><postback>HELLO</postback></button>", resolved) self.assertEquals("<button><text>SAY HELLO</text><postback>HELLO</postback></button>", root.to_xml(self._client_context))
def test_url_button_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) button = TemplateButtonNode() button._text = TemplateWordNode("Servusai.com") button._url = TemplateWordNode("http://Servusai.com") root.append(button) resolved = root.resolve(self._client_context) self.assertIsNotNone(resolved) self.assertEquals("<button><text>Servusai.com</text><url>http://Servusai.com</url></button>", resolved) self.assertEquals("<button><text>Servusai.com</text><url>http://Servusai.com</url></button>", root.to_xml(self._client_context))
def test_url_button_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) button = TemplateButtonNode() button._text = TemplateWordNode("Servusai.com") button._url = TemplateWordNode("http://Servusai.com") root.append(button) resolved = root.resolve(self._client_context) self.assertIsNotNone(resolved) self.assertEqual("<button><text>Servusai.com</text><url>http://Servusai.com</url></button>", resolved) self.assertEqual("<button><text>Servusai.com</text><url>http://Servusai.com</url></button>", root.to_xml(self._client_context))
def test_url_postback_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) button = TemplateButtonNode() button._text = TemplateWordNode("SAY HELLO") button._postback = TemplateWordNode("HELLO") root.append(button) resolved = root.resolve(self._client_context) self.assertIsNotNone(resolved) self.assertEqual("<button><text>SAY HELLO</text><postback>HELLO</postback></button>", resolved) self.assertEqual("<button><text>SAY HELLO</text><postback>HELLO</postback></button>", root.to_xml(self._client_context))