def load_configuration(self, arguments): super(OOBTestClient, self).load_configuration(arguments) self.configuration.brain_configuration.files.aiml_files._files = os.path.dirname( __file__) default = BrainOOBConfiguration("default") default._classname = "programy.utils.oob.default.DefaultOutOfBoundsProcessor" self.configuration.brain_configuration.oob._default = default
def load_config_section(self, file_config, brain_config, bot_root): oobs = file_config.get_section("oob", brain_config) if oobs is not None: oob_keys = file_config.get_keys(oobs) for name in oob_keys: oob = BrainOOBConfiguration(name) oob.load_config_section(file_config, oobs, bot_root) if name == 'default': self._default = oob else: self._oobs[name] = oob else: logging.warning( "Config section [oobs] missing from Brain, no oobs loaded")
def load_config_section(self, configuration_file, configuration, bot_root): oobs = configuration_file.get_section("oob", configuration) if oobs is not None: oob_keys = configuration_file.get_keys(oobs) for name in oob_keys: oob = BrainOOBConfiguration(name) oob.load_config_section(configuration_file, oobs, bot_root) if name == 'default': self._default = oob else: self._oobs[name] = oob else: if logging.getLogger().isEnabledFor(logging.WARNING): logging.warning( "Config section [oobs] missing from Brain, no oobs loaded")
def test_default_without_data(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: oobs: default: """, ConsoleConfiguration(), ".") brain_config = yaml.get_section("brain") self.assertIsNotNone(brain_config) oobs_config = yaml.get_section("oobs", brain_config) self.assertIsNotNone(oobs_config) oob_config = BrainOOBConfiguration("default") oob_config.load_config_section(yaml, oobs_config, ".") self.assertIsNone(oob_config.classname)
def test_oob_with_data(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: oobs: default: classname: programy.utils.oob.default.DefaultOutOfBandProcessor """, ConsoleConfiguration(), ".") brain_config = yaml.get_section("brain") self.assertIsNotNone(brain_config) oobs_config = yaml.get_section("oobs", brain_config) self.assertIsNotNone(oobs_config) oob_config = BrainOOBConfiguration("default") oob_config.load_config_section(yaml, oobs_config, ".") self.assertEqual("programy.utils.oob.default.DefaultOutOfBandProcessor", oob_config.classname)