def test_node_invalid_class(self): root = TemplateNode() node = TemplateExtensionNode() node.path = "programytest.parser.template.node_tests.test_extension.MockExtensionOther" root.append(node) with self.assertRaises(Exception): root.resolve(self._client_context)
def test_to_xml(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateExtensionNode() node.path = "programytest.parser.template.node_tests.test_extension.MockExtension" node.append(TemplateWordNode("Test")) root.append(node) xml = root.xml_tree(self._client_context) self.assertIsNotNone(xml) xml_str = ET.tostring(xml, "utf-8").decode("utf-8") self.assertEqual('<template><extension path="programytest.parser.template.node_tests.test_extension.MockExtension">Test</extension></template>', xml_str)
def test_node_no_data(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateExtensionNode() self.assertIsNotNone(node) self.assertIsNone(node.path) node.path = "programytest.parser.template.node_tests.test_extension.MockExtension" self.assertEqual("programytest.parser.template.node_tests.test_extension.MockExtension", node.path) root.append(node) self.assertEqual(len(root.children), 1) self.assertEqual(root.resolve(self._client_context), "VALID")
def parse_extension_expression(self, expression, branch): extension_node = TemplateExtensionNode() branch.children.append(extension_node) if 'path' in expression.attrib: extension_node.path = expression.attrib['path'] head_text = self.get_text_from_element(expression) self.parse_text(head_text, extension_node) for child in expression: if child.tag == 'path': extension_node.path = self.get_text_from_element(child) else: self.parse_tag_expression(child, extension_node) tail_text = self.get_tail_from_element(child) self.parse_text(tail_text, extension_node)
def test_node_with_data(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateExtensionNode() self.assertIsNotNone(node) self.assertIsNone(node.path) node.append(TemplateWordNode("Test")) node.path = "programytest.parser.template.node_tests.test_extension.MockExtension" self.assertEqual( "programytest.parser.template.node_tests.test_extension.MockExtension", node.path) root.append(node) self.assertEqual(len(root.children), 1) self.assertEqual(root.resolve(self._bot, self._clientid), "Test")
def __init__(self): TemplateExtensionNode.__init__(self)
def test_node_invalid_class(self): root = TemplateNode() node = TemplateExtensionNode() node.path = "programytest.parser.template.node_tests.test_extension.MockExtensionOther" root.append(node) self.assertEqual(root.resolve(self._client_context), "")
def test_node_invalid_class(self): root = TemplateNode() node = TemplateExtensionNode() node.path = "programytest.parser.template.node_tests.test_extension.MockExtensionOther" root.append(node) self.assertEqual(root.resolve(self._bot, self._clientid), "")