def test_load_from_file(self): client_config = ClientConfiguration() json = JSONConfigurationFile(client_config) self.assertIsNotNone(json) json.load_from_file(os.path.dirname(__file__)+"/test_json.json", ",") self.assertIsNotNone(json.json_data) brain = json.get_section("brain") self.assertIsNotNone(brain) files = json.get_section("files", brain) self.assertIsNotNone(files) aiml = json.get_section("aiml", files) self.assertIsNotNone(aiml) files = json.get_section("files", aiml) self.assertIsNotNone(files) self.assertEqual(files, "/aiml") extension = json.get_section("extension", aiml) self.assertIsNotNone(extension) self.assertEqual(extension, ".aiml") directories = json.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( """ 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_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_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_load_config_data_yaml(self): client_config = ClientConfiguration() ConfigurationFactory.load_configuration_from_file( client_config, os.path.dirname(__file__) + "/test_yaml.yaml") self.assert_config_data(client_config)
def test_load_from_text(self): client_config = ClientConfiguration() xml = XMLConfigurationFile(client_config) self.assertIsNotNone(xml) xml.load_from_text( """<?xml version="1.0" encoding="UTF-8"?> <configuration> <brain> <supress_warnings>True</supress_warnings> <allow_system_aiml>True</allow_system_aiml> <allow_learn_aiml>True</allow_learn_aiml> <allow_learnf_aiml>True</allow_learnf_aiml> <files> <aiml> <files>/aiml</files> <extension>.aiml</extension> <directories>True</directories> </aiml> <sets> <files>/sets</files> <extension>.txt</extension> <directories>False</directories> </sets> <maps> <files>/maps</files> <extension>.txt</extension> <directories>True</directories> </maps> <denormal>denormal.txt</denormal> <normal>normal.txt</normal> <gender>gender.txt</gender> <person>person.txt</person> <person2>person2.txt</person2> <predicates>predicates.txt</predicates> <pronouns>pronouns.txt</pronouns> <properties>properties.txt</properties> <triples>triples.txt</triples> <preprocessors>preprocessors.txt</preprocessors> <postprocessors>postprocessors.txt</postprocessors> </files> <services> <REST> <path>programy.utils.services.rest.GenericRESTService</path> </REST> <Pannous> <path>programy.utils.services.pannous.PannousService</path> </Pannous> <Pandora> <path>programy.utils.services.pandora.PandoraService</path> </Pandora> <Wikipedia> <path>programy.utils.services.wikipedia.WikipediaService</path> </Wikipedia> </services> </brain> <bot> <prompt>>>></prompt> <default_response>Sorry, I don't have an answer for that!</default_response> <exit_response>So long, and thanks for the fish!</exit_response> <initial_question>Hi, how can I help you?</initial_question> </bot> </configuration> """, ",")
def __init__(self): ClientConfiguration.__init__(self) self._webchat_config = WebChatConfiguration()
def __init__(self): ClientConfiguration.__init__(self) self._twitter_config = TwitterConfiguration()
def __init__(self): ClientConfiguration.__init__(self) self._rest_config = RestConfiguration()
def test_load_from_text(self): client_config = ClientConfiguration() json = JSONConfigurationFile(client_config) self.assertIsNotNone(json) json.load_from_text(""" { "brain": { "supress_warnings": false, "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>" } }""", ",")
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 dump_to_file: /tmp/braintree.txt 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.assertEqual("/tmp/braintree.txt", brain_config.dump_to_file) 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 __init__(self): ClientConfiguration.__init__(self) self._rest_config = RestConfiguration()
def __init__(self): ClientConfiguration.__init__(self) self._xmpp_config = XmppConfiguration()
def load_configuration(self, arguments): self.configuration = ClientConfiguration() ConfigurationFactory.load_configuration_from_file( self.configuration, os.path.dirname(__file__) + "/testconfig.yaml")
def __init__(self): ClientConfiguration.__init__(self) self._facebook_config = FacebookConfiguration()