示例#1
0
    def test_to_xml(self):
        root = TemplateNode()
        node = TemplateRestNode()
        root.append(node)
        word1 = TemplateWordNode("Word1")
        node.append(word1)
        word2 = TemplateWordNode("Word2")
        node.append(word2)

        xml = root.xml_tree(self._client_context)
        self.assertIsNotNone(xml)
        xml_str = ET.tostring(xml, "utf-8").decode("utf-8")
        self.assertEqual("<template><rest>Word1 Word2</rest></template>", xml_str)
示例#2
0
    def test_node_one_word(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateRestNode()
        self.assertIsNotNone(node)

        root.append(node)
        word1 = TemplateWordNode("Word1")
        node.append(word1)

        self.assertEqual(root.resolve(None, "clientid"), "NIL")
示例#3
0
    def test_node_one_word(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateRestNode()
        self.assertIsNotNone(node)

        root.append(node)
        word1 = TemplateWordNode("Word1")
        node.append(word1)

        self.assertEqual(root.resolve(self._client_context), "unknown")
示例#4
0
    def test_node_one_word(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateRestNode()
        self.assertIsNotNone(node)

        root.append(node)
        word1 = TemplateWordNode("Word1")
        node.append(word1)

        self.assertEqual(root.resolve(self._client_context), "NIL")
示例#5
0
    def test_to_xml_no_words(self):
        root = TemplateNode()
        node = TemplateRestNode()
        root.append(node)

        xml = root.xml_tree(self.bot, self.clientid)
        self.assertIsNotNone(xml)
        xml_str = ET.tostring(xml, "utf-8").decode("utf-8")
        self.assertEqual("<template><rest /></template>", xml_str)
示例#6
0
    def test_node_no_words(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateRestNode()
        self.assertIsNotNone(node)

        root.append(node)

        self.assertEqual(root.resolve(None, "clientid"), "NIL")
示例#7
0
    def test_node(self):
        root = TemplateNode()
        self.assertIsNotNone(root)
        self.assertIsNotNone(root.children)
        self.assertEqual(len(root.children), 0)

        node = TemplateRestNode()
        self.assertIsNotNone(node)

        root.append(node)
        word1 = TemplateWordNode("Word1")
        node.append(word1)
        word2 = TemplateWordNode("Word2")
        node.append(word2)
        word3 = TemplateWordNode("Word3")
        node.append(word3)

        self.assertEqual(root.resolve(self._bot, self._clientid), "Word2 Word3")
示例#8
0
    def test_to_xml(self):
        root = TemplateNode()
        node = TemplateRestNode()
        root.append(node)
        word1 = TemplateWordNode("Word1")
        node.append(word1)
        word2 = TemplateWordNode("Word2")
        node.append(word2)

        xml = root.xml_tree(self._client_context)
        self.assertIsNotNone(xml)
        xml_str = ET.tostring(xml, "utf-8").decode("utf-8")
        self.assertEqual("<template><rest>Word1 Word2</rest></template>", xml_str)
示例#9
0
 def __init__(self):
     TemplateRestNode.__init__(self)
示例#10
0
 def __init__(self):
     TemplateRestNode.__init__(self)
示例#11
0
 def __init__(self, json):
     TemplateRestNode.__init__(self)
     self._json = json