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._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_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 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)
def test_defaults(self): braintree_config = BrainBraintreeConfiguration() data = {} braintree_config.to_yaml(data, True) BrainBraintreeConfigurationTests.assert_defaults(self, data)