def test_node(self): test_bot = Bot(Brain(BrainConfiguration()), BotConfiguration()) topic_element = ET.fromstring('<topic>*</topic>') that_element = ET.fromstring('<that>*</that>') pattern_element = ET.fromstring("<pattern>hello world</pattern>") test_bot.brain._aiml_parser.pattern_parser.add_pattern_to_graph(pattern_element, topic_element, that_element, None) loader = SetLoader() test_bot.brain.sets.add_set("testset", loader.load_from_text(""" val1 val2 val3 """)) root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateVocabularyNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) self.assertEquals(root.resolve(test_bot, "testid"), '5')
def test_node(self): test_bot = Bot(Brain(BrainConfiguration()), BotConfiguration()) root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateProgramNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) test_bot.brain.properties.add_property("fullname", "testbot") test_bot.brain.properties.add_property("version", "1.0.0") self.assertEqual(root.resolve(test_bot, "testid"), "testbot 1.0.0")