Example #1
0
class ClientConfiguration(object):
    def __init__(self):
        self._brain_config = BrainConfiguration()
        self._bot_config = BotConfiguration()

    @property
    def brain_configuration(self):
        return self._brain_config

    @property
    def bot_configuration(self):
        return self._bot_config

    def load_config_data(self, config_file, bot_root):
        self._brain_config.load_config_section(config_file, bot_root)
        self._bot_config.load_config_section(config_file, bot_root)
Example #2
0
    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)
Example #3
0
    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)