def test_to_xml(self): root = TemplateNode() root.append(TemplateIdNode()) xml = root.xml_tree(self._client_context) self.assertIsNotNone(xml) xml_str = ET.tostring(xml, "utf-8").decode("utf-8") self.assertEqual("<template><id /></template>", xml_str)
def test_output_child(self): node = TemplateNode() node.append(TemplateWordNode("Word1")) node.append(TemplateIdNode()) self.assertIsNotNone(node) node.append(TemplateWordNode("Word1")) node.output_child(node, "\t", "\n", print) node.output_child(node, "\t", "\n", outputLog)
def test_to_xml_composite(self): node = TemplateNode() node.append(TemplateWordNode("Word1")) node.append(TemplateIdNode()) srai = TemplateSRAINode() srai.append(TemplateWordNode("Srai1")) node.append(srai) node.append(TemplateWordNode("Word2")) self.assertEqual("Word1 <id /> <srai>Srai1</srai> Word2", node.to_xml(self._client_context))
def test_xml_tree_simple_composite(self): node = TemplateNode() node.append(TemplateWordNode("Word1")) node.append(TemplateIdNode()) srai = TemplateSRAINode() srai.append(TemplateWordNode("Srai1")) node.append(srai) node.append(TemplateWordNode("Word2")) xml = node.xml_tree(self._client_context) xml_str = ET.tostring(xml, "utf-8").decode("utf-8") self.assertEqual("<template>Word1 <id /> <srai>Srai1</srai> Word2</template>", xml_str)
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateIdNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) self.assertEqual(root.resolve(self._client_context), "testclient")
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateIdNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) # TODO check documentation on this, AIML spec says this returns the bot name self.assertEqual(root.resolve(self._client_context), "testclient")
def test_node_without_clientid(self): self._client_context.client._id = None node = TemplateIdNode() self.assertIsNotNone(node) self.assertEquals("", node.resolve(self._client_context))