def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ twitter: polling: true polling_interval: 59 streaming: true use_status: true use_direct_message: true auto_follow: true storage: file storage_location: ./storage/twitter.data welcome_message: Thanks for following me """, ".") twitter_config = TwitterConfiguration() twitter_config.load_config_section(yaml, ".") self.assertTrue(twitter_config.polling) self.assertEqual(59, twitter_config.polling_interval) self.assertTrue(twitter_config.streaming) self.assertTrue(twitter_config.use_status) self.assertTrue(twitter_config.use_direct_message) self.assertTrue(twitter_config.auto_follow) self.assertEquals("file", twitter_config.storage) self.assertEquals("./storage/twitter.data", twitter_config.storage_location) self.assertEquals("Thanks for following me", twitter_config.welcome_message)
def test_init_with_blank_data(self): with self.assertRaises(Exception): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" """, ".")
def test_init_with_blank_data(self): with self.assertRaises(Exception): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" """, ".")
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ bot: license_keys: $BOT_ROOT/config/license.keys prompt: ">>>" initial_question: Hi, how can I help you today? default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! override_predicates: true """, ".") bot_config = BotConfiguration() bot_config.load_config_section(yaml, ".") self.assertEqual("./config/license.keys", bot_config.license_keys) self.assertEqual(">>>", bot_config.prompt) self.assertEqual("Hi, how can I help you today?", bot_config.initial_question) self.assertEqual("Sorry, I don't have an answer for that!", bot_config.default_response) self.assertEqual("So long, and thanks for the fish!", bot_config.exit_response) self.assertTrue(bot_config.override_predicates)
def test_init_with_empty_sections(self): with self.assertRaises(Exception): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: files: """, ".")
def test_init_with_files_only(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ brain: files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: false denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt bot: """, ".") self.assertIsNotNone(client_config.bot_configuration) self.assertIsNotNone(client_config.bot_configuration.prompt) self.assertEquals(">>> ", client_config.bot_configuration.prompt) self.assertIsNotNone(client_config.bot_configuration.default_response) self.assertEquals("Sorry, I don't have an answer for that right now", client_config.bot_configuration.default_response) self.assertIsNotNone(client_config.bot_configuration.exit_response) self.assertEquals("Bye!", client_config.bot_configuration.exit_response) self.assertIsNotNone(client_config.bot_configuration.initial_question) self.assertEquals("Hello", client_config.bot_configuration.initial_question) self.assertIsNotNone(client_config.brain_configuration) self.assertFalse(client_config.brain_configuration.supress_warnings) self.assertTrue(client_config.brain_configuration.allow_system_aiml) self.assertTrue(client_config.brain_configuration.allow_learn_aiml) self.assertTrue(client_config.brain_configuration.allow_learnf_aiml) self.assertIsNotNone(client_config.brain_configuration._services) self.assertEqual(0, len(client_config.brain_configuration._services))
def test_init_with_empty_sections(self): with self.assertRaises(Exception): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ brain: files: """, ".")
def test_init_with_files_only(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: false denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt bot: """, ".") self.assertIsNotNone(client_config.bot_configuration) self.assertIsNotNone(client_config.bot_configuration.prompt) self.assertEquals(">>> ", client_config.bot_configuration.prompt) self.assertIsNotNone(client_config.bot_configuration.default_response) self.assertEquals("Sorry, I don't have an answer for that right now", client_config.bot_configuration.default_response) self.assertIsNotNone(client_config.bot_configuration.exit_response) self.assertEquals("Bye!", client_config.bot_configuration.exit_response) self.assertIsNotNone(client_config.bot_configuration.initial_question) self.assertEquals("Hello", client_config.bot_configuration.initial_question) self.assertIsNotNone(client_config.brain_configuration) self.assertFalse(client_config.brain_configuration.supress_warnings) self.assertTrue(client_config.brain_configuration.allow_system_aiml) self.assertTrue(client_config.brain_configuration.allow_learn_aiml) self.assertTrue(client_config.brain_configuration.allow_learnf_aiml) self.assertIsNotNone(client_config.brain_configuration._services) self.assertEqual(0, len(client_config.brain_configuration._services))
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ webchat: host: 127.0.0.1 port: 5000 debug: false """, ".") webchat_config = WebChatConfiguration() webchat_config.load_config_section(yaml, ".") self.assertEqual("127.0.0.1", webchat_config.host) self.assertEqual(5000, webchat_config.port) self.assertEqual(False, webchat_config.debug)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" bot: prompt: ">>>" initial_question: Hi, how can I help you today? default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! """, ".") bot_config = BotConfiguration() bot_config.load_config_section(yaml, ".") self.assertEqual(">>>", bot_config.prompt) self.assertEqual("Hi, how can I help you today?", bot_config.initial_question) self.assertEqual("Sorry, I don't have an answer for that!", bot_config.default_response) self.assertEqual("So long, and thanks for the fish!", bot_config.exit_response)
def get_config_by_name(cls, client_config, file_format): file_format = file_format.lower() if file_format == 'yaml': return YamlConfigurationFile(client_config) elif file_format == 'json': return JSONConfigurationFile(client_config) elif file_format == 'xml': return XMLConfigurationFile(client_config) else: raise Exception("Unsupported configuration format:", file_format)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ rest: host: 127.0.0.1 port: 5000 debug: false use_api_keys: false """, ".") rest_config = RestConfiguration() rest_config.load_config_section(yaml, ".") self.assertEqual("127.0.0.1", rest_config.host) self.assertEqual(5000, rest_config.port) self.assertEqual(False, rest_config.debug) self.assertEqual(False, rest_config.use_api_keys)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ bot: prompt: ">>>" initial_question: Hi, how can I help you today? default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! """, ".") bot_config = BotConfiguration() bot_config.load_config_section(yaml, ".") self.assertEqual(">>>", bot_config.prompt) self.assertEqual("Hi, how can I help you today?", bot_config.initial_question) self.assertEqual("Sorry, I don't have an answer for that!", bot_config.default_response) self.assertEqual("So long, and thanks for the fish!", bot_config.exit_response)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" xmpp: server: talk.google.com port: 5222 xep_0030: true xep_0004: true xep_0060: true xep_0199: true """, ".") xmpp_config = XmppConfiguration() xmpp_config.load_config_section(yaml, ".") self.assertEquals('talk.google.com', xmpp_config.server) self.assertEquals(5222, xmpp_config.port) self.assertTrue(xmpp_config.xep_0030) self.assertTrue(xmpp_config.xep_0004) self.assertTrue(xmpp_config.xep_0060) self.assertTrue(xmpp_config.xep_0199)
def test_load_from_file(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_file(os.path.dirname(__file__)+"/test_yaml.yaml", ",") self.assertIsNotNone(yaml.yaml_data) brain = yaml.get_section("brain") self.assertIsNotNone(brain) files = yaml.get_section("files", brain) self.assertIsNotNone(files) aiml = yaml.get_section("aiml", files) self.assertIsNotNone(aiml) files = yaml.get_section("files", aiml) self.assertIsNotNone(files) self.assertEqual(files, "/aiml") extension = yaml.get_section("extension", aiml) self.assertIsNotNone(extension) self.assertEqual(extension, ".aiml") directories = yaml.get_section("directories", aiml) self.assertIsNotNone(directories) self.assertEqual(directories, True)
def test_init(self): client_config = XmppClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: true denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt services: REST: path: programy.utils.services.rest.GenericRESTService Pannous: path: programy.utils.services.pannous.PannousService Pandora: path: programy.utils.services.pandora.PandoraService Wikipedia: path: programy.utils.services.wikipedia.WikipediaService bot: prompt: ">>>" default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! initial_question: Hi, how can I help you? xmpp: server: talk.google.com port: 5222 xep_0030: true xep_0004: true xep_0060: true xep_0199: true """, ".") self.assertIsNotNone(client_config.bot_configuration) self.assertIsNotNone(client_config.brain_configuration) self.assertIsNotNone(client_config.xmpp_configuration)
def test_load_from_text(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: true denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt services: REST: path: programy.utils.services.rest.GenericRESTService Pannous: path: programy.utils.services.pannous.PannousService Pandora: path: programy.utils.services.pandora.PandoraService Wikipedia: path: programy.utils.services.wikipedia.WikipediaService bot: prompt: ">>>" default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! initial_question: Hi, how can I help you? """, ".") self.assertIsNotNone(yaml.yaml_data) brain = yaml.get_section("brain") self.assertIsNotNone(brain) files = yaml.get_section("files", brain) self.assertIsNotNone(files) aiml = yaml.get_section("aiml", files) self.assertIsNotNone(aiml) files = yaml.get_section("files", aiml) self.assertIsNotNone(files) self.assertEqual(files, "/aiml") extension = yaml.get_section("extension", aiml) self.assertIsNotNone(extension) self.assertEqual(extension, ".aiml") directories = yaml.get_section("directories", aiml) self.assertIsNotNone(directories) self.assertEqual(directories, True)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: false denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt services: REST: path: programy.utils.services.rest.GenericRESTService Pannous: path: programy.utils.services.pannous.PannousService Pandora: path: programy.utils.services.pandora.PandoraService Wikipedia: path: programy.utils.services.wikipedia.WikipediaService bot: prompt: ">>>" default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! initial_question: Hi, how can I help you? override_predicates: true """, ".") self.assertIsNotNone(client_config.bot_configuration) self.assertIsNotNone(client_config.bot_configuration.prompt) self.assertEquals(">>>", client_config.bot_configuration.prompt) self.assertIsNotNone(client_config.bot_configuration.default_response) self.assertEquals("Sorry, I don't have an answer for that!", client_config.bot_configuration.default_response) self.assertIsNotNone(client_config.bot_configuration.exit_response) self.assertEquals("So long, and thanks for the fish!", client_config.bot_configuration.exit_response) self.assertIsNotNone(client_config.bot_configuration.initial_question) self.assertEquals("Hi, how can I help you?", client_config.bot_configuration.initial_question) self.assertIsNotNone(client_config.brain_configuration) self.assertTrue(client_config.brain_configuration.supress_warnings) self.assertTrue(client_config.brain_configuration.allow_system_aiml) self.assertTrue(client_config.brain_configuration.allow_learn_aiml) self.assertTrue(client_config.brain_configuration.allow_learnf_aiml) self.assertIsNotNone(client_config.brain_configuration._aiml_files) self.assertIsInstance(client_config.brain_configuration._aiml_files, BrainFileConfiguration) self.assertEquals("/aiml", client_config.brain_configuration._aiml_files.files) self.assertEquals( ".aiml", client_config.brain_configuration._aiml_files.extension) self.assertTrue( client_config.brain_configuration._aiml_files.directories) self.assertIsNotNone(client_config.brain_configuration._set_files) self.assertIsInstance(client_config.brain_configuration._set_files, BrainFileConfiguration) self.assertEquals("/sets", client_config.brain_configuration._set_files.files) self.assertEquals( ".txt", client_config.brain_configuration._set_files.extension) self.assertFalse( client_config.brain_configuration._set_files.directories) self.assertIsNotNone(client_config.brain_configuration._map_files) self.assertIsInstance(client_config.brain_configuration._map_files, BrainFileConfiguration) self.assertEquals("/maps", client_config.brain_configuration._map_files.files) self.assertEquals( ".txt", client_config.brain_configuration._map_files.extension) self.assertFalse( client_config.brain_configuration._map_files.directories) self.assertIsNotNone(client_config.brain_configuration._denormal) self.assertEquals("denormal.txt", client_config.brain_configuration._denormal) self.assertIsNotNone(client_config.brain_configuration._normal) self.assertEquals("normal.txt", client_config.brain_configuration._normal) self.assertIsNotNone(client_config.brain_configuration._gender) self.assertEquals("gender.txt", client_config.brain_configuration._gender) self.assertIsNotNone(client_config.brain_configuration._person) self.assertEquals("person.txt", client_config.brain_configuration._person) self.assertIsNotNone(client_config.brain_configuration._person2) self.assertEquals("person2.txt", client_config.brain_configuration._person2) self.assertIsNotNone(client_config.brain_configuration._predicates) self.assertEquals("predicates.txt", client_config.brain_configuration._predicates) self.assertIsNotNone(client_config.brain_configuration._pronouns) self.assertEquals("pronouns.txt", client_config.brain_configuration._pronouns) self.assertIsNotNone(client_config.brain_configuration._properties) self.assertEquals("properties.txt", client_config.brain_configuration._properties) self.assertIsNotNone(client_config.brain_configuration._triples) self.assertEquals("triples.txt", client_config.brain_configuration._triples) self.assertIsNotNone(client_config.brain_configuration._preprocessors) self.assertEquals("preprocessors.txt", client_config.brain_configuration._preprocessors) self.assertIsNotNone(client_config.brain_configuration._postprocessors) self.assertEquals("postprocessors.txt", client_config.brain_configuration._postprocessors) self.assertIsNotNone(client_config.brain_configuration._services) self.assertEquals(4, len(client_config.brain_configuration._services))
def test_init(self): client_config = TwitterClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: true denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt services: REST: path: programy.utils.services.rest.GenericRESTService Pannous: path: programy.utils.services.pannous.PannousService Pandora: path: programy.utils.services.pandora.PandoraService Wikipedia: path: programy.utils.services.wikipedia.WikipediaService bot: prompt: ">>>" default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! initial_question: Hi, how can I help you? twitter: polling: true polling_interval: 59 streaming: true use_status: true use_direct_message: true auto_follow: true storage: file storage_location: ./storage/twitter.data welcome_message: Thanks for following me """, ".") self.assertIsNotNone(client_config.bot_configuration) self.assertIsNotNone(client_config.brain_configuration) self.assertIsNotNone(client_config.twitter_configuration)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: $BOT_ROOT/aiml extension: .aiml directories: false sets: files: $BOT_ROOT/sets extension: .txt directories: false maps: files: $BOT_ROOT/maps extension: .txt directories: false denormal: $BOT_ROOT/config/denormal.txt normal: $BOT_ROOT/config/normal.txt gender: $BOT_ROOT/config/gender.txt person: $BOT_ROOT/config/person.txt person2: $BOT_ROOT/config/person2.txt predicates: $BOT_ROOT/config/predicates.txt pronouns: $BOT_ROOT/config/pronouns.txt properties: $BOT_ROOT/config/properties.txt triples: $BOT_ROOT/config/triples.txt preprocessors: $BOT_ROOT/config/preprocessors.conf postprocessors: $BOT_ROOT/config/postprocessors.conf """, ".") brain_config = BrainConfiguration() brain_config.load_config_section(yaml, ".") self.assertEqual(True, brain_config.supress_warnings) self.assertEqual(True, brain_config.allow_system_aiml) self.assertEqual(True, brain_config.allow_learn_aiml) self.assertEqual(True, brain_config.allow_learnf_aiml) self.assertIsNotNone(brain_config.aiml_files) self.assertIsNotNone(brain_config.set_files) self.assertIsNotNone(brain_config.map_files) self.assertEqual("./config/denormal.txt", brain_config.denormal) self.assertEqual("./config/normal.txt", brain_config.normal) self.assertEqual("./config/gender.txt", brain_config.gender) self.assertEqual("./config/person.txt", brain_config.person) self.assertEqual("./config/person2.txt", brain_config.person2) self.assertEqual("./config/predicates.txt", brain_config.predicates) self.assertEqual("./config/pronouns.txt", brain_config.pronouns) self.assertEqual("./config/properties.txt", brain_config.properties) self.assertEqual("./config/triples.txt", brain_config.triples) self.assertEqual("./config/preprocessors.conf", brain_config.preprocessors) self.assertEqual("./config/postprocessors.conf", brain_config.postprocessors) self.assertIsNotNone(brain_config.services)
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: /aiml extension: .aiml directories: true sets: files: /sets extension: .txt directories: false maps: files: /maps extension: .txt directories: false denormal: denormal.txt normal: normal.txt gender: gender.txt person: person.txt person2: person2.txt predicates: predicates.txt pronouns: pronouns.txt properties: properties.txt triples: triples.txt preprocessors: preprocessors.txt postprocessors: postprocessors.txt services: REST: path: programy.utils.services.rest.GenericRESTService Pannous: path: programy.utils.services.pannous.PannousService Pandora: path: programy.utils.services.pandora.PandoraService Wikipedia: path: programy.utils.services.wikipedia.WikipediaService bot: prompt: ">>>" default_response: Sorry, I don't have an answer for that! exit_response: So long, and thanks for the fish! initial_question: Hi, how can I help you? override_predicates: true """, ".") self.assertIsNotNone(client_config.bot_configuration) self.assertIsNotNone(client_config.bot_configuration.prompt) self.assertEquals(">>>", client_config.bot_configuration.prompt) self.assertIsNotNone(client_config.bot_configuration.default_response) self.assertEquals("Sorry, I don't have an answer for that!", client_config.bot_configuration.default_response) self.assertIsNotNone(client_config.bot_configuration.exit_response) self.assertEquals("So long, and thanks for the fish!", client_config.bot_configuration.exit_response) self.assertIsNotNone(client_config.bot_configuration.initial_question) self.assertEquals("Hi, how can I help you?", client_config.bot_configuration.initial_question) self.assertIsNotNone(client_config.brain_configuration) self.assertTrue(client_config.brain_configuration.supress_warnings) self.assertTrue(client_config.brain_configuration.allow_system_aiml) self.assertTrue(client_config.brain_configuration.allow_learn_aiml) self.assertTrue(client_config.brain_configuration.allow_learnf_aiml) self.assertIsNotNone(client_config.brain_configuration._aiml_files) self.assertIsInstance(client_config.brain_configuration._aiml_files, BrainFileConfiguration) self.assertEquals("/aiml", client_config.brain_configuration._aiml_files.files) self.assertEquals(".aiml", client_config.brain_configuration._aiml_files.extension) self.assertTrue(client_config.brain_configuration._aiml_files.directories) self.assertIsNotNone(client_config.brain_configuration._set_files) self.assertIsInstance(client_config.brain_configuration._set_files, BrainFileConfiguration) self.assertEquals("/sets", client_config.brain_configuration._set_files.files) self.assertEquals(".txt", client_config.brain_configuration._set_files.extension) self.assertFalse(client_config.brain_configuration._set_files.directories) self.assertIsNotNone(client_config.brain_configuration._map_files) self.assertIsInstance(client_config.brain_configuration._map_files, BrainFileConfiguration) self.assertEquals("/maps", client_config.brain_configuration._map_files.files) self.assertEquals(".txt", client_config.brain_configuration._map_files.extension) self.assertFalse(client_config.brain_configuration._map_files.directories) self.assertIsNotNone(client_config.brain_configuration._denormal) self.assertEquals("denormal.txt", client_config.brain_configuration._denormal) self.assertIsNotNone(client_config.brain_configuration._normal) self.assertEquals("normal.txt", client_config.brain_configuration._normal) self.assertIsNotNone(client_config.brain_configuration._gender) self.assertEquals("gender.txt", client_config.brain_configuration._gender) self.assertIsNotNone(client_config.brain_configuration._person) self.assertEquals("person.txt", client_config.brain_configuration._person) self.assertIsNotNone(client_config.brain_configuration._person2) self.assertEquals("person2.txt", client_config.brain_configuration._person2) self.assertIsNotNone(client_config.brain_configuration._predicates) self.assertEquals("predicates.txt", client_config.brain_configuration._predicates) self.assertIsNotNone(client_config.brain_configuration._pronouns) self.assertEquals("pronouns.txt", client_config.brain_configuration._pronouns) self.assertIsNotNone(client_config.brain_configuration._properties) self.assertEquals("properties.txt", client_config.brain_configuration._properties) self.assertIsNotNone(client_config.brain_configuration._triples) self.assertEquals("triples.txt", client_config.brain_configuration._triples) self.assertIsNotNone(client_config.brain_configuration._preprocessors) self.assertEquals("preprocessors.txt", client_config.brain_configuration._preprocessors) self.assertIsNotNone(client_config.brain_configuration._postprocessors) self.assertEquals("postprocessors.txt", client_config.brain_configuration._postprocessors) self.assertIsNotNone(client_config.brain_configuration._services) self.assertEquals(4, len(client_config.brain_configuration._services))
def test_init(self): client_config = ClientConfiguration() yaml = YamlConfigurationFile(client_config) self.assertIsNotNone(yaml) yaml.load_from_text( """ brain: supress_warnings: true allow_system_aiml: true allow_learn_aiml: true allow_learnf_aiml: true files: aiml: files: $BOT_ROOT/aiml extension: .aiml directories: false sets: files: $BOT_ROOT/sets extension: .txt directories: false maps: files: $BOT_ROOT/maps extension: .txt directories: false denormal: $BOT_ROOT/config/denormal.txt normal: $BOT_ROOT/config/normal.txt gender: $BOT_ROOT/config/gender.txt person: $BOT_ROOT/config/person.txt person2: $BOT_ROOT/config/person2.txt predicates: $BOT_ROOT/config/predicates.txt pronouns: $BOT_ROOT/config/pronouns.txt properties: $BOT_ROOT/config/properties.txt triples: $BOT_ROOT/config/triples.txt preprocessors: $BOT_ROOT/config/preprocessors.conf postprocessors: $BOT_ROOT/config/postprocessors.conf """, ".") brain_config = BrainConfiguration() brain_config.load_config_section(yaml, ".") self.assertEqual(True, brain_config.supress_warnings) self.assertEqual(True, brain_config.allow_system_aiml) self.assertEqual(True, brain_config.allow_learn_aiml) self.assertEqual(True, brain_config.allow_learnf_aiml) self.assertIsNotNone(brain_config.aiml_files) self.assertIsNotNone(brain_config.set_files) self.assertIsNotNone(brain_config.map_files) self.assertEqual("./config/denormal.txt", brain_config.denormal) self.assertEqual("./config/normal.txt", brain_config.normal) self.assertEqual("./config/gender.txt", brain_config.gender) self.assertEqual("./config/person.txt", brain_config.person) self.assertEqual("./config/person2.txt", brain_config.person2) self.assertEqual("./config/predicates.txt", brain_config.predicates) self.assertEqual("./config/pronouns.txt", brain_config.pronouns) self.assertEqual("./config/properties.txt", brain_config.properties) self.assertEqual("./config/triples.txt", brain_config.triples) self.assertEqual("./config/preprocessors.conf", brain_config.preprocessors) self.assertEqual("./config/postprocessors.conf", brain_config.postprocessors) self.assertIsNotNone(brain_config.services)