def __init__(self, section_name="brain"): self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._security = BrainSecuritiesConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() self._debugfiles = BrainDebugFilesConfiguration() BaseContainerConfigurationData.__init__(self, section_name)
def test_dump_no_create(self): config = BrainBraintreeConfiguration() config._create = False config._save_as_user = "******" mgr = BraintreeManager(config) client = TestClient() client_context = client.create_client_context("testid") mgr.dump_brain_tree(client_context)
def test_with_no_data(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: """, ConsoleConfiguration(), ".") brain_config = yaml.get_section("brain") braintree_config = BrainBraintreeConfiguration() braintree_config.load_config_section(yaml, brain_config, ".") self.assertFalse(braintree_config.create)
def test_dump_brain_tree_no_storage(self): tmpdir = os.path.dirname(__file__) + os.sep + self.TEST_DIRECTORY treefile = tmpdir + os.sep + 'braintree.xml' client = TestClient() client_context = client.create_client_context("testid") configure = BrainBraintreeConfiguration() configure._create = True braintree = BraintreeManager(configure) braintree.dump_brain_tree(client_context) self.assertFalse(os.path.exists(treefile))
def test_with_no_data(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: """, ConsoleConfiguration(), ".") brain_config = yaml.get_section("brain") braintree_config = BrainBraintreeConfiguration() braintree_config.load_config_section(yaml, brain_config, ".") self.assertIsNone(braintree_config.file) self.assertIsNone(braintree_config.content)
def test_dump_brain_tree_invalid(self): tmpdir = os.path.dirname(__file__) + os.sep + self.TEST_DIRECTORY treefile = tmpdir + os.sep + 'braintree.csv' client = BrainTreeTestClient(tree_type=FileStore.CSV_FORMAT, filename=treefile) client_context = client.create_client_context("testid") configure = BrainBraintreeConfiguration() configure._create = True braintree = BraintreeManager(configure) braintree.dump_brain_tree(client_context) self.assertFalse(os.path.exists(treefile))
def __init__(self, section_name="brain"): self._bot_name = None self._manager_name = None self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._services = BrainServicesConfiguration() self._security = BrainSecuritiesConfiguration() self._oob = BrainOOBSConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() self._debugfiles = BrainDebugFilesConfiguration() self._nlu = BrainNluConfiguration() BaseContainerConfigurationData.__init__(self, section_name)
def test_with_data(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" brain: braintree: file: /tmp/braintree.xml content: xml """, ConsoleConfiguration(), ".") brain_config = yaml.get_section("brain") braintree_config = BrainBraintreeConfiguration() braintree_config.load_config_section(yaml, brain_config, ".") self.assertEquals("/tmp/braintree.xml", braintree_config.file) self.assertEquals("xml", braintree_config.content)
def to_yaml(self, data, defaults=True): self.config_to_yaml(data, BrainOverridesConfiguration(), defaults) self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults) self.config_to_yaml(data, BrainBinariesConfiguration(), defaults) self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults) self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults) self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults) self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults) self.config_to_yaml(data, BrainDebugFilesConfiguration(), defaults)
def __init__(self, section_name="brain"): self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._nodes = BrainNodesConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._files = BrainFilesConfiguration() self._services = BrainServicesConfiguration() self._security = BrainSecuritiesConfiguration() self._oob = BrainOOBSConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() BaseContainerConfigurationData.__init__(self, section_name)
def test_dump_create_(self): tmpdir = self.get_temp_dir() brainfile = tmpdir + os.sep + "braintree.bin" config = BrainBraintreeConfiguration() config._create = True config._save_as_user = "******" mgr = BraintreeManager(config) if os.path.exists(brainfile): os.remove(brainfile) client = TestClient() client.add_braintree_store(brainfile) client_context = client.create_client_context("testid") mgr.dump_brain_tree(client_context) self.assertTrue(os.path.exists(brainfile)) if os.path.exists(brainfile): os.remove(brainfile)
class BrainConfiguration(BaseContainerConfigurationData): def __init__(self, section_name="brain"): self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._services = BrainServicesConfiguration() self._openchatbots = BrainOpenChatBotsConfiguration() self._security = BrainSecuritiesConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() self._debugfiles = BrainDebugFilesConfiguration() BaseContainerConfigurationData.__init__(self, section_name) @property def overrides(self): return self._overrides @property def defaults(self): return self._defaults @property def binaries(self): return self._binaries @property def braintree(self): return self._braintree @property def services(self): return self._services @property def openchatbots(self): return self._openchatbots @property def security(self): return self._security @property def dynamics(self): return self._dynamics @property def tokenizer(self): return self._tokenizer @property def debugfiles(self): return self._debugfiles def check_for_license_keys(self, license_keys): self._overrides.check_for_license_keys(license_keys) self._defaults.check_for_license_keys(license_keys) self._binaries.check_for_license_keys(license_keys) self._braintree.check_for_license_keys(license_keys) self._services.check_for_license_keys(license_keys) self._openchatbots.check_for_license_keys(license_keys) self._security.check_for_license_keys(license_keys) self._dynamics.check_for_license_keys(license_keys) self._tokenizer.check_for_license_keys(license_keys) self._debugfiles.check_for_license_keys(license_keys) BaseContainerConfigurationData.check_for_license_keys( self, license_keys) def load_configuration(self, configuration_file, brain_config, bot_root, subs: Substitutions = None): if brain_config is not None: self._overrides.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._defaults.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._binaries.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._braintree.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._services.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._openchatbots.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._security.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._dynamics.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._tokenizer.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._debugfiles.load_config_section(configuration_file, brain_config, bot_root, subs=subs) def to_yaml(self, data, defaults=True): self.config_to_yaml(data, BrainOverridesConfiguration(), defaults) self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults) self.config_to_yaml(data, BrainBinariesConfiguration(), defaults) self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults) self.config_to_yaml(data, BrainServicesConfiguration(), defaults) self.config_to_yaml(data, BrainOpenChatBotsConfiguration(), defaults) self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults) self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults) self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults) self.config_to_yaml(data, BrainDebugFilesConfiguration(), defaults)
class BrainConfiguration(BaseContainerConfigurationData): def __init__(self, section_name="brain"): self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._nodes = BrainNodesConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._files = BrainFilesConfiguration() self._services = BrainServicesConfiguration() self._security = BrainSecuritiesConfiguration() self._oob = BrainOOBSConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() BaseContainerConfigurationData.__init__(self, section_name) @property def overrides(self): return self._overrides @property def defaults(self): return self._defaults @property def nodes(self): return self._nodes @property def binaries(self): return self._binaries @property def braintree(self): return self._braintree @property def files(self): return self._files @property def services(self): return self._services @property def security(self): return self._security @property def oob(self): return self._oob @property def dynamics(self): return self._dynamics @property def tokenizer(self): return self._tokenizer def load_configuration(self, configuration_file, bot_root): brain_config = configuration_file.get_section(self.section_name) if brain_config is not None: self._overrides.load_config_section(configuration_file, brain_config, bot_root) self._defaults.load_config_section(configuration_file, brain_config, bot_root) self._nodes.load_config_section(configuration_file, brain_config, bot_root) self._binaries.load_config_section(configuration_file, brain_config, bot_root) self._braintree.load_config_section(configuration_file, brain_config, bot_root) self._files.load_config_section(configuration_file, brain_config, bot_root) self._services.load_config_section(configuration_file, brain_config, bot_root) self._security.load_config_section(configuration_file, brain_config, bot_root) self._oob.load_config_section(configuration_file, brain_config, bot_root) self._dynamics.load_config_section(configuration_file, brain_config, bot_root) self._tokenizer.load_config_section(configuration_file, brain_config, bot_root) def to_yaml(self, data, defaults=True): self.config_to_yaml(data, BrainOverridesConfiguration(), defaults) self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults) self.config_to_yaml(data, BrainNodesConfiguration(), defaults) self.config_to_yaml(data, BrainBinariesConfiguration(), defaults) self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults) self.config_to_yaml(data, BrainFilesConfiguration(), defaults) self.config_to_yaml(data, BrainServicesConfiguration(), defaults) self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults) self.config_to_yaml(data, BrainOOBSConfiguration(), defaults) self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults) self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)
class BrainConfiguration(BaseContainerConfigurationData): def __init__(self, section_name="brain"): self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._nodes = BrainNodesConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._files = BrainFilesConfiguration() self._services = BrainServicesConfiguration() self._security = BrainSecuritiesConfiguration() self._oob = BrainOOBSConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() BaseContainerConfigurationData.__init__(self, section_name) @property def overrides(self): return self._overrides @property def defaults(self): return self._defaults @property def nodes(self): return self._nodes @property def binaries(self): return self._binaries @property def braintree(self): return self._braintree @property def files(self): return self._files @property def services(self): return self._services @property def security(self): return self._security @property def oob(self): return self._oob @property def dynamics(self): return self._dynamics @property def tokenizer(self): return self._tokenizer def load_configuration(self, configuration_file, bot_root): brain_config = configuration_file.get_section(self.section_name) if brain_config is not None: self._overrides.load_config_section(configuration_file, brain_config, bot_root) self._defaults.load_config_section(configuration_file, brain_config, bot_root) self._nodes.load_config_section(configuration_file, brain_config, bot_root) self._binaries.load_config_section(configuration_file, brain_config, bot_root) self._braintree.load_config_section(configuration_file, brain_config, bot_root) self._files.load_config_section(configuration_file, brain_config, bot_root) self._services.load_config_section(configuration_file, brain_config, bot_root) self._security.load_config_section(configuration_file, brain_config, bot_root) self._oob.load_config_section(configuration_file, brain_config, bot_root) self._dynamics.load_config_section(configuration_file, brain_config, bot_root) self._tokenizer.load_config_section(configuration_file, brain_config, bot_root) def to_yaml(self, data, defaults=True): self.config_to_yaml(data, BrainOverridesConfiguration(), defaults) self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults) self.config_to_yaml(data, BrainNodesConfiguration(), defaults) self.config_to_yaml(data, BrainBinariesConfiguration(), defaults) self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults) self.config_to_yaml(data, BrainFilesConfiguration(), defaults) self.config_to_yaml(data, BrainServicesConfiguration(), defaults) self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults) self.config_to_yaml(data, BrainOOBSConfiguration(), defaults) self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults) self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults)
class BrainConfiguration(BaseContainerConfigurationData): def __init__(self, section_name="brain"): self._bot_name = None self._manager_name = None self._overrides = BrainOverridesConfiguration() self._defaults = BrainDefaultsConfiguration() self._binaries = BrainBinariesConfiguration() self._braintree = BrainBraintreeConfiguration() self._services = BrainServicesConfiguration() self._security = BrainSecuritiesConfiguration() self._oob = BrainOOBSConfiguration() self._dynamics = BrainDynamicsConfiguration() self._tokenizer = BrainTokenizerConfiguration() self._debugfiles = BrainDebugFilesConfiguration() self._nlu = BrainNluConfiguration() BaseContainerConfigurationData.__init__(self, section_name) @property def bot_name(self): return self._bot_name @property def manager_name(self): return self._manager_name @property def overrides(self): return self._overrides @property def defaults(self): return self._defaults @property def binaries(self): return self._binaries @property def braintree(self): return self._braintree @property def services(self): return self._services @property def security(self): return self._security @property def oob(self): return self._oob @property def dynamics(self): return self._dynamics @property def tokenizer(self): return self._tokenizer @property def debugfiles(self): return self._debugfiles @property def nlu(self): return self._nlu def check_for_license_keys(self, license_keys): self._overrides.check_for_license_keys(license_keys) self._defaults.check_for_license_keys(license_keys) self._binaries.check_for_license_keys(license_keys) self._braintree.check_for_license_keys(license_keys) self._services.check_for_license_keys(license_keys) self._security.check_for_license_keys(license_keys) self._oob.check_for_license_keys(license_keys) self._dynamics.check_for_license_keys(license_keys) self._tokenizer.check_for_license_keys(license_keys) self._debugfiles.check_for_license_keys(license_keys) self._nlu.check_for_license_keys(license_keys) BaseContainerConfigurationData.check_for_license_keys( self, license_keys) def load_configuration(self, configuration_file, bot_root, subs: Substitutions = None): brain_config = configuration_file.get_section(self.section_name) if brain_config is not None: self._bot_name = configuration_file.get_option( brain_config, "bot_name") self._manager_name = configuration_file.get_option( brain_config, "manager_name") self._overrides.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._defaults.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._binaries.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._braintree.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._services.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._security.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._oob.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._dynamics.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._tokenizer.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._debugfiles.load_config_section(configuration_file, brain_config, bot_root, subs=subs) self._nlu.load_config_section(configuration_file, brain_config, bot_root, subs=subs) def to_yaml(self, data, defaults=True): self.config_to_yaml(data, BrainOverridesConfiguration(), defaults) self.config_to_yaml(data, BrainDefaultsConfiguration(), defaults) self.config_to_yaml(data, BrainBinariesConfiguration(), defaults) self.config_to_yaml(data, BrainBraintreeConfiguration(), defaults) self.config_to_yaml(data, BrainServicesConfiguration(), defaults) self.config_to_yaml(data, BrainSecuritiesConfiguration(), defaults) self.config_to_yaml(data, BrainOOBSConfiguration(), defaults) self.config_to_yaml(data, BrainDynamicsConfiguration(), defaults) self.config_to_yaml(data, BrainTokenizerConfiguration(), defaults) self.config_to_yaml(data, BrainDebugFilesConfiguration(), defaults) self.config_to_yaml(data, BrainNluConfiguration(), defaults)
def test_defaults(self): braintree_config = BrainBraintreeConfiguration() data = {} braintree_config.to_yaml(data, True) BrainBraintreeConfigurationTests.assert_defaults(self, data)