def test_to_xml(self): root = TemplateNode() node = TemplateDenormalizeNode() root.append(node) node.append(TemplateWordNode("Test")) xml = root.xml_tree(self.bot, self.clientid) self.assertIsNotNone(xml) xml_str = ET.tostring(xml, "utf-8").decode("utf-8") self.assertEqual("<template><denormalize>Test</denormalize></template>", xml_str)
def test_to_xml(self): root = TemplateNode() node = TemplateDenormalizeNode() root.append(node) node.append(TemplateWordNode("Test")) xml = root.xml_tree(self._client_context) self.assertIsNotNone(xml) xml_str = ET.tostring(xml, "utf-8").decode("utf-8") self.assertEqual("<template><denormalize>Test</denormalize></template>", xml_str)
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateDenormalizeNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) node.append(TemplateWordNode("keiff dot uk")) self._client_context.brain.denormals.process_splits([" dot uk", ".uk"]) self.assertEqual(root.resolve(self._client_context), "keiff.uk")
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateDenormalizeNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) node.append(TemplateWordNode("keiff dot uk")) self.bot.brain.denormals.process_splits([" dot uk",".uk"]) self.assertEqual(root.resolve(self.bot, self.clientid), "keiff.uk")
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateDenormalizeNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) node.append(TemplateWordNode("keiff dot com")) self._client_context.brain.denormals.add_to_lookup(" DOT COM ", [re.compile("(^DOT COM | DOT COM | DOT COM$)", re.IGNORECASE), ".com"]) self.assertEqual(root.resolve(self._client_context), "keiff.com")
def test_node(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateDenormalizeNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) node.append(TemplateWordNode("keiff dot com")) self._client_context.brain.denormals.add_to_lookup("dot com", ".com") self.assertEqual(root.resolve(self._client_context), "keiff.com")