示例#1
0
 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))
示例#2
0
 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))
示例#3
0
    def test_to_xml(self):
        root = TemplateNode()
        node = TemplateSRAINode()
        root.append(node)
        node.append(TemplateWordNode("Hello"))

        xml = root.xml_tree(self._client_context)
        self.assertIsNotNone(xml)
        xml_str = ET.tostring(xml, "utf-8").decode("utf-8")
        self.assertEqual("<template><srai>Hello</srai></template>", xml_str)
示例#4
0
    def test_to_xml(self):
        root = TemplateNode()
        node = TemplateSRAINode()
        root.append(node)
        node.append(TemplateWordNode("Hello"))

        xml = root.xml_tree(self._client_context)
        self.assertIsNotNone(xml)
        xml_str = ET.tostring(xml, "utf-8").decode("utf-8")
        self.assertEqual("<template><srai>Hello</srai></template>", xml_str)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
    def test_node(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateSRAINode()
        self.assertIsNotNone(node)

        root.append(node)
        self.assertEqual(len(root.children), 1)

        node.append(TemplateWordNode("Hello"))
        self.assertEqual(len(node.children), 1)

        self._client_context.bot.response = "Hiya"
        self.assertEqual(root.resolve(self._client_context), "Hiya")
示例#8
0
    def test_node(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateSRAINode()
        self.assertIsNotNone(node)

        root.append(node)
        self.assertEqual(len(root.children), 1)

        node.append(TemplateWordNode("Hello"))
        self.assertEqual(len(node.children), 1)

        self._client_context.bot.response = "Hiya"
        self.assertEqual(root.resolve(self._client_context), "Hiya")
示例#9
0
 def __init__(self):
     TemplateSRAINode.__init__(self)
示例#10
0
 def __init__(self):
     TemplateSRAINode.__init__(self)