def test_node_invalid_json_words(self): node = TemplateFirstNode() self.assertIsNotNone(node) node.append(TemplateWordNode("Rubbish not json")) self.assertEqual(node.resolve(self._client_context), "Rubbish")
def test_to_xml_no_words(self): root = TemplateNode() node = TemplateFirstNode() 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><first /></template>", xml_str)
def test_node_no_words(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateFirstNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(root.resolve(self._bot, self._clientid), "NIL")
def test_node_no_words(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateFirstNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(root.resolve(self._client_context), "unknown")
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateFirstNode() 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), "Word1")
def test_to_xml(self): root = TemplateNode() node = TemplateFirstNode() 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><first>Word1 Word2</first></template>", xml_str)
def __init__(self): TemplateFirstNode.__init__(self)
def __init__(self, json): TemplateFirstNode.__init__(self) self._json = json