def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( files=os.path.dirname(__file__)) self.configuration.brain_configuration._set_files = BrainFileConfiguration( files=os.path.dirname(__file__) + "/sets", extension=".txt") self.configuration.brain_configuration._map_files = BrainFileConfiguration( files=os.path.dirname(__file__) + "/maps", extension=".txt")
def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( os.path.dirname(__file__), ".aiml", False) self.configuration.brain_configuration._set_files = BrainFileConfiguration( os.path.dirname(__file__) + "/sets", ".txt", False) self.configuration.brain_configuration._map_files = BrainFileConfiguration( os.path.dirname(__file__) + "/maps", ".txt", False)
def test_node(self): if os.path.exists('/tmp/leanf.aiml'): os.remove('/tmp/leanf.aiml') root = TemplateNode() self.assertIsNotNone(root) learn = TemplateLearnfNode() self.assertIsNotNone(learn) learn._pattern = ET.fromstring("<pattern>HELLO LEARN</pattern>") learn._topic = ET.fromstring("<topic>*</topic>") learn._that = ET.fromstring("<that>*</that>") learn._template = TemplateWordNode("LEARN") root.append(learn) self.assertEqual(1, len(root.children)) self.bot.brain._configuration._aiml_files = BrainFileConfiguration( "/tmp", ".aiml", False) resolved = root.resolve(self.bot, self.clientid) self.assertIsNotNone(resolved) self.assertEqual("", resolved) self.assertTrue(os.path.exists('/tmp/learnf.aiml'))
def test_init(self): file_config = BrainFileConfiguration(files="/aiml", extension=".txt", directories=True) self.assertEqual(file_config.files, "/aiml") self.assertEqual(file_config.extension, ".txt") self.assertEqual(file_config.directories, True)
def test_learnf(self): LearnfAIMLTests.test_client.bot.brain._configuration._aiml_files = BrainFileConfiguration("/tmp", ".aiml", False) response = LearnfAIMLTests.test_client.bot.ask_question("test", "MY NAME IS FRED") self.assertIsNotNone(response) self.assertEqual(response, "OK, I will remember your name is FRED") response = LearnfAIMLTests.test_client.bot.ask_question("test", "WHAT IS MY NAME") self.assertIsNotNone(response) self.assertEqual(response, "YOUR NAME IS FRED")
def test_learnf_simple(self): template = ET.fromstring(""" <template> <learnf> <category> <pattern>HELLO <eval>WORLD</eval> THERE</pattern> <template>HIYA</template> </category> </learnf> </template> """) self.test_bot.brain._configuration._aiml_files = BrainFileConfiguration("/tmp", ".aiml", False) ast = self.parser.parse_template_expression(template) self.assertIsNotNone(ast) self.assertIsInstance(ast, TemplateNode) self.assertIsNotNone(ast.children) self.assertEqual(len(ast.children), 1) learn_node = ast.children[0] self.assertIsNotNone(learn_node) self.assertIsInstance(learn_node, TemplateLearnNode) self.assertIsNotNone(learn_node._pattern) self.assertIsInstance(learn_node._pattern, ET.Element) self.assertIsNotNone(learn_node._topic) self.assertIsInstance(learn_node._topic, ET.Element) self.assertIsNotNone(learn_node._that) self.assertIsInstance(learn_node._that, ET.Element) self.assertIsNotNone(learn_node._template) self.assertIsInstance(learn_node._template, TemplateNode) resolved = learn_node.resolve(self.test_bot, self.test_clientid) self.assertEqual(resolved, "") response = self.test_bot.ask_question(self.test_clientid, "HELLO WORLD THERE") self.assertEqual("HIYA", response)
def load_configuration(self, arguments): super(TopicStarTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(files=os.path.dirname(__file__))
def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( file=os.path.dirname(__file__) + os.sep + 'star_udc.aiml')
def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(files=os.path.dirname(__file__)) self.configuration.brain_configuration._denormal = os.path.dirname(__file__)+"/denormal.txt"
def setUp(self): LearnfAIMLTests.test_client = LearnfTestClient() LearnfAIMLTests.test_client.bot.brain._configuration._aiml_files = BrainFileConfiguration("/tmp", ".aiml", False) self.learnf_path = "%s/learnf%s" % (LearnfAIMLTests.test_client.bot.brain._configuration._aiml_files.files, LearnfAIMLTests.test_client.bot.brain._configuration._aiml_files.extension) if os.path.exists(self.learnf_path): os.remove(self.learnf_path)
def test_init_defaults(self): file_config = BrainFileConfiguration(files="/aiml") self.assertEqual(file_config.files, "/aiml") self.assertEqual(file_config.extension, ".aiml") self.assertEqual(file_config.directories, False)
def load_configuration(self, arguments): super(TelecomsMinutesTestsClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( files=os.path.dirname(__file__))
def load_configuration(self, arguments): super(BankBalanceTestsClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( files=os.path.dirname(__file__))
def load_configuration(self, arguments): super(TelecomsMinutesTestsClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( os.path.dirname(__file__) + "/../../../../aiml/extensions/telecoms", ".aiml", False)
def load_configuration(self, arguments): super(GeoCodeTestsClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( os.path.dirname(__file__) + "/../../../../aiml/extensions/geocode", ".aiml", False)
def load_configuration(self, arguments): super(ConversationalTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration(os.path.dirname(__file__), ".aiml", False)
def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( file=os.path.dirname(__file__) + os.sep + 'hash_udc.aiml') self.configuration.bot_configuration._empty_string = "YEMPTY"