def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( os.path.dirname(__file__) + "/../aiml_tests/test_files/pattern_set", ".aiml", False) self.configuration.brain_configuration._set_files = BrainFileConfiguration( os.path.dirname(__file__) + "/../aiml_tests/test_files/pattern_set/sets", ".txt", False)
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 load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( os.path.dirname(__file__) + "/../aiml_tests/test_files/normalize", ".aiml", False) self.configuration.brain_configuration._normal = os.path.dirname( __file__) + "/../aiml_tests/test_files/normalize/normal.txt"
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 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(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( "/Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/src/test/aiml_tests/test_files/underline_star", ".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(SrTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( os.path.dirname(__file__) + "/../aiml_tests/test_files/sr", ".aiml", False)
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._gender = os.path.dirname( __file__) + "/gender.txt"
def load_configuration(self, arguments): super(BasicTestClient, self).load_configuration(arguments) self.configuration.brain_configuration._aiml_files = BrainFileConfiguration( "/Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/src/test/aiml_tests/test_files/denormalize", ".aiml", False) self.configuration.brain_configuration._denormal = "/Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/rosie/config/denormal.txt"