Example #1
0
 def load_os_specific_configuration(self, yaml, linux_filename,
                                    windows_filename):
     if os.name == 'posix':
         yaml.load_from_file(
             os.path.dirname(__file__) + os.sep + linux_filename,
             ConsoleConfiguration(), os.path.dirname(__file__))
     elif os.name == 'nt':
         yaml.load_from_file(
             os.path.dirname(__file__) + os.sep + windows_filename,
             ConsoleConfiguration(), os.path.dirname(__file__))
     else:
         raise Exception("Unknown os [%s]" % os.name)
Example #2
0
    def test_authorisation_with_data_denied_text(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            security:
                authorisation:
                    classname: programy.security.authorise.passthrough.PassThroughAuthorisationService
                    denied_text: Authorisation Failed
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("security", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainSecurityConfiguration("authorisation")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual(
            "programy.security.authorise.passthrough.PassThroughAuthorisationService",
            service_config.classname)
        self.assertEqual("Authorisation Failed", service_config.denied_text)
        self.assertIsNone(service_config.denied_srai)
Example #3
0
    def test_authentication_with_data_denied_srai(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            security:
                authentication:
                    classname: programy.security.authenticate.passthrough.PassThroughAuthenticationService
                    denied_srai: AUTHENTICATION_FAILED
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("security", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainSecurityConfiguration("authentication")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual(
            "programy.security.authenticate.passthrough.PassThroughAuthenticationService",
            service_config.classname)
        self.assertEqual("AUTHENTICATION_FAILED", service_config.denied_srai)
        self.assertEqual(BrainSecurityConfiguration.DEFAULT_ACCESS_DENIED,
                         service_config.denied_text)
Example #4
0
    def test_wikipedia_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                Wikipedia:
                    classname: programy.utils.services.wikipediaservice.WikipediaService
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("services", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainServiceConfiguration("Wikipedia")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual(
            "programy.utils.services.wikipediaservice.WikipediaService",
            service_config.classname)
        self.assertIsNone(service_config.method)
        self.assertIsNone(service_config.host)
        self.assertIsNone(service_config.port)
        self.assertIsNone(service_config.url)
Example #5
0
    def test_pandora_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                Pandora:
                    classname: programy.utils.services.pandora.PandoraService
                    url: http://www.pandorabots.com/pandora/talk-xml
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("services", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainServiceConfiguration("Pandora")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual("programy.utils.services.pandora.PandoraService",
                         service_config.classname)
        self.assertEqual("http://www.pandorabots.com/pandora/talk-xml",
                         service_config.url)
        self.assertIsNone(service_config.method)
        self.assertIsNone(service_config.host)
        self.assertIsNone(service_config.port)
Example #6
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        bot:
            spelling:
              classname: programy.spelling.norvig.NorvigSpellingChecker
              corpus: $BOT_ROOT/corpus.txt
              alphabet: abcdefghijklmnopqrstuvwxyz
              check_before: true
              check_and_retry: true
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("bot")

        spelling_config = BotSpellingConfiguration()
        spelling_config.load_config_section(yaml, bot_config, ".")

        self.assertEquals("programy.spelling.norvig.NorvigSpellingChecker",
                          spelling_config.classname)
        self.assertEquals("./corpus.txt", spelling_config.corpus)
        self.assertEquals("abcdefghijklmnopqrstuvwxyz",
                          spelling_config.alphabet)
        self.assertTrue(spelling_config.check_before)
        self.assertTrue(spelling_config.check_and_retry)
Example #7
0
    def test_rest_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                REST:
                    classname: programy.utils.services.rest.GenericRESTService
                    method: GET
                    host: 0.0.0.0
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("services", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainServiceConfiguration("REST")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual("programy.utils.services.rest.GenericRESTService",
                         service_config.classname)
        self.assertEqual("GET", service_config.method)
        self.assertEqual("0.0.0.0", service_config.host)
        self.assertIsNone(service_config.port)
        self.assertIsNone(service_config.url)
Example #8
0
    def test_without_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        bot:
        """, ConsoleConfiguration(), ".")

        bot_config = BotConfiguration()
        bot_config.load_configuration(yaml, ".")

        self.assertIsNone(bot_config.license_keys)
        self.assertEqual(">>> ", bot_config.prompt)
        self.assertEqual("Hello", bot_config.initial_question)
        self.assertEqual("", bot_config.initial_question_srai)
        self.assertEqual("", bot_config.default_response)
        self.assertEqual("", bot_config.default_response_srai)
        self.assertEqual("Bye!", bot_config.exit_response)
        self.assertEqual("", bot_config.exit_response_srai)
        self.assertEqual("", bot_config.empty_string)
        self.assertEqual(bot_config.max_question_recursion, 100)
        self.assertEqual(bot_config.max_question_timeout, -1)
        self.assertEqual(bot_config.max_search_depth, 100)
        self.assertEqual(bot_config.max_search_timeout, -1)
        self.assertTrue(bot_config.override_properties)

        self.assertIsNotNone(bot_config.spelling)
Example #9
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        bot:
            conversations:
              max_histories: 666
              initial_topic: topic1
              restore_last_topic: true
              type: file
              config_name: file_storage
        
            file_storage:
              dir: $BOT_ROOT/conversations
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("bot")

        convo_config = BotConversationsConfiguration()
        convo_config.load_config_section(yaml, bot_config, ".")

        self.assertEquals(convo_config.section_name, "conversations")

        self.assertEquals(666, convo_config.max_histories)
        self.assertEquals("topic1", convo_config.initial_topic)
        self.assertTrue(convo_config.restore_last_topic)

        self.assertEquals(convo_config.type, "file")
        self.assertIsNotNone(convo_config.storage)
Example #10
0
    def test_with_file_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            files:
                aiml:
                    file: $BOT_ROOT/aiml/test.aiml
                    errors: /tmp/y-bot-errors.txt
                    duplicates: /tmp/y-bot-duplicates.txt
                    conversation: /tmp/y-bot-conversation.txt
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)

        aiml_config = BrainAIMLFileConfiguration()
        aiml_config.load_config_section(yaml, files_config, ".")

        self.assertEqual("./aiml/test.aiml", aiml_config.file)
        self.assertEqual("aiml", aiml_config.extension)
        self.assertFalse(aiml_config.directories)
        self.assertEqual("/tmp/y-bot-errors.txt", aiml_config.errors.filename)
        self.assertEqual("/tmp/y-bot-duplicates.txt",
                         aiml_config.duplicates.filename)
        self.assertEqual("/tmp/y-bot-conversation.txt",
                         aiml_config.conversation.filename)
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
            twitter:
              polling: true
              polling_interval: 59
              streaming: true
              use_status: true
              use_direct_message: true
              auto_follow: true
              storage: file
              storage_location: ./storage/twitter.data
              welcome_message: Thanks for following me
        """, ConsoleConfiguration(), ".")

        twitter_config = TwitterConfiguration()
        twitter_config.load_config_section(yaml, ".")

        self.assertTrue(twitter_config.polling)
        self.assertEqual(59, twitter_config.polling_interval)
        self.assertTrue(twitter_config.streaming)
        self.assertTrue(twitter_config.use_status)
        self.assertTrue(twitter_config.use_direct_message)
        self.assertTrue(twitter_config.auto_follow)
        self.assertEquals("file", twitter_config.storage)
        self.assertEquals("./storage/twitter.data",
                          twitter_config.storage_location)
        self.assertEquals("Thanks for following me",
                          twitter_config.welcome_message)
Example #12
0
    def test_pannous_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                Pannous:
                    classname: programy.services.pannous.PannousService
                    url: http://weannie.pannous.com/api
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        services_config = yaml.get_section("services", brain_config)
        self.assertIsNotNone(services_config)

        service_config = BrainServiceConfiguration("Pannous")
        service_config.load_config_section(yaml, services_config, ".")

        self.assertEqual("programy.services.pannous.PannousService",
                         service_config.classname)
        self.assertEqual("http://weannie.pannous.com/api", service_config.url)
        self.assertIsNone(service_config.method)
        self.assertIsNone(service_config.host)
        self.assertIsNone(service_config.port)
Example #13
0
    def test_with_new_format_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            files:
                aiml:
                    errors:
                      file: /tmp/y-bot_errors.csv
                      format: csv
                      encoding: utf-8
                      delete_on_start: true
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)
        aiml_config = yaml.get_section("aiml", files_config)
        self.assertIsNotNone(aiml_config)

        debugfile_config = DebugFileConfiguration("errors")
        debugfile_config.load_config_section(yaml, aiml_config, ".")

        self.assertEquals("/tmp/y-bot_errors.csv", debugfile_config.filename)
        self.assertEquals("csv", debugfile_config.file_format)
        self.assertEquals("utf-8", debugfile_config.encoding)
        self.assertTrue(debugfile_config.delete_on_start)
Example #14
0
    def test_load_from_text_multi_files(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        configuration = yaml.load_from_text("""
            brain:

                files:
                    aiml:
                        files: |
                                $BOT_ROOT/test-aiml
                                $BOT_ROOT/my-aiml
                        extension: .test-aiml
                        directories: true
                        errors: /tmp/y-bot_errors.txt
                        duplicates: /tmp/y-bot_duplicates.txt
                        conversation: /tmp/y-bot_conversation.txt
                    sets:
                        files: $BOT_ROOT/test-sets
                        extension: .test-txt
                        directories: true
                    maps:
                        files: $BOT_ROOT/test-maps
                        extension: .test-txt
                        directories: true
            """, ConsoleConfiguration(), ".")

        self.assertIsNotNone(configuration)

        self.assertTrue(configuration.brain_configuration.files.aiml_files.has_multiple_files())
        self.assertFalse(configuration.brain_configuration.files.aiml_files.has_single_file())

        self.assertEqual(configuration.brain_configuration.files.aiml_files.files, ['./test-aiml', './my-aiml'])
        self.assertEqual(configuration.brain_configuration.files.set_files.files, ["./test-sets"])
        self.assertEqual(configuration.brain_configuration.files.map_files.files, ["./test-maps"])
Example #15
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                REST:
                    classname: programy.utils.services.rest.GenericRESTService
                    method: GET
                    host: 0.0.0.0
                Pannous:
                    classname: programy.utils.services.pannous.PannousService
                    url: http://weannie.pannous.com/api
                Pandora:
                    classname: programy.utils.services.pandora.PandoraService
                    url: http://www.pandorabots.com/pandora/talk-xml
                Wikipedia:
                    classname: programy.utils.services.wikipediaservice.WikipediaService
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        services_config = BrainServicesConfiguration()
        services_config.load_config_section(yaml, brain_config, ".")

        self.assertTrue(services_config.exists("REST"))
        self.assertTrue(services_config.exists("Pannous"))
        self.assertTrue(services_config.exists("Pandora"))
        self.assertTrue(services_config.exists("Wikipedia"))
        self.assertFalse(services_config.exists("Other"))
Example #16
0
    def test_load_additionals(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        configuration = yaml.load_from_text(
            """
            brain:

                services:
                    Authentication:
                        classname: programy.utils.services.authenticate.passthrough.PassThroughAuthenticationService
                        denied_srai: ACCESS_DENIED

            """, ConsoleConfiguration(), ".")

        self.assertIsNotNone(configuration)

        self.assertTrue(
            configuration.brain_configuration.services.exists(
                "Authentication"))
        auth_service = configuration.brain_configuration.services.service(
            "Authentication")
        self.assertIsNotNone(auth_service)

        self.assertTrue(auth_service.exists("denied_srai"))
        self.assertEqual("ACCESS_DENIED", auth_service.value("denied_srai"))
Example #17
0
    def test_with_files_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            files:
                aiml:
                    files: $BOT_ROOT/aiml
                    extension: .aiml
                    directories: true
                    errors: /tmp/y-bot_errors.txt
                    duplicates: /tmp/y-bot_duplicates.txt
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")
        self.assertIsNotNone(brain_config)
        files_config = yaml.get_section("files", brain_config)
        self.assertIsNotNone(files_config)

        aiml_config = BrainAIMLFileConfiguration()
        aiml_config.load_config_section(yaml, files_config, ".")

        self.assertEqual("./aiml", aiml_config.files)
        self.assertEqual(".aiml", aiml_config.extension)
        self.assertTrue(aiml_config.directories)
        self.assertEqual("/tmp/y-bot_errors.txt", aiml_config.errors)
        self.assertEqual("/tmp/y-bot_duplicates.txt", aiml_config.duplicates)
Example #18
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        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!
            empty_string: YEMPTY
            exit_response: So long, and thanks for the fish!
            override_predicates: true
            max_recursion: 10
            spelling:
              classname: programy.utils.spelling.checker.SpellingChecker
              alphabet: 'abcdefghijklmnopqrstuvwxyz'
              corpus: $BOT_ROOT/corpus.txt
              check_before: true
              check_and_retry: true
        """, ConsoleConfiguration(), ".")

        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("YEMPTY", bot_config.empty_string)
        self.assertEqual(10, bot_config.max_recursion)
        self.assertTrue(bot_config.override_predicates)

        self.assertIsNotNone(bot_config.spelling)
        self.assertEqual("programy.utils.spelling.checker.SpellingChecker", bot_config.spelling.classname)
Example #19
0
    def test_load_from_configuration_no_data(self):
        collection = DynamicsCollection()
        self.assertIsNotNone(collection)

        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            dynamic:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamics_config = BrainDynamicsConfiguration()
        dynamics_config.load_config_section(yaml, brain_config, ".")

        collection.load_from_configuration(dynamics_config)

        self.assertIsNotNone(collection.dynamic_sets)
        self.assertTrue(collection.is_dynamic_set("NUMBER"))

        self.assertIsNotNone(collection.dynamic_maps)
        self.assertTrue(collection.is_dynamic_map("PLURAL"))
        self.assertTrue(collection.is_dynamic_map("SINGULAR"))
        self.assertTrue(collection.is_dynamic_map("PREDECESSOR"))
        self.assertTrue(collection.is_dynamic_map("SUCCESSOR"))

        self.assertIsNotNone(collection.dynamic_vars)
Example #20
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            binaries:
              save_binary: true
              load_binary: true
              binary_filename: $BOT_ROOT/output/y-bot.brain
              load_aiml_on_binary_fail: true
              dump_to_file: $BOT_ROOT/output/braintree.txt
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        binaries_config = BrainBinariesConfiguration()
        binaries_config.load_config_section(yaml, brain_config, ".")

        self.assertTrue(binaries_config.save_binary)
        self.assertTrue(binaries_config.load_binary)
        self.assertEquals("./output/y-bot.brain",
                          binaries_config.binary_filename)
        self.assertTrue(binaries_config.load_aiml_on_binary_fail)
        self.assertEquals("./output/braintree.txt",
                          binaries_config.dump_to_file)
Example #21
0
 def test_load_from_file(self):
     xml = XMLConfigurationFile()
     self.assertIsNotNone(xml)
     configuration = xml.load_from_file(
         os.path.dirname(__file__) + "/test_xml.xml",
         ConsoleConfiguration(), ".")
     self.assertIsNotNone(configuration)
     self.assert_configuration(configuration)
Example #22
0
 def test_load_from_file(self):
     yaml = YamlConfigurationFile()
     self.assertIsNotNone(yaml)
     configuration = yaml.load_from_file(
         os.path.dirname(__file__) + os.sep + "test_yaml.yaml",
         ConsoleConfiguration(), ".")
     self.assertIsNotNone(configuration)
     self.assert_configuration(configuration)
Example #23
0
 def test_load_from_file(self):
     json = JSONConfigurationFile()
     self.assertIsNotNone(json)
     configuration = json.load_from_file(
         os.path.dirname(__file__) + os.sep + "test_json.json",
         ConsoleConfiguration(), ".")
     self.assertIsNotNone(configuration)
     self.assert_configuration(configuration)
Example #24
0
    def test_oob_processing(self):

        yaml = YamlConfigurationFile()
        yaml.load_from_file(os.path.dirname(__file__)+"/test_brain.yaml", ConsoleConfiguration(), os.path.dirname(__file__))

        brain_config = BrainConfiguration()
        brain_config.load_config_section(yaml, ".")

        brain = Brain(brain_config)

        self.assertEqual("", brain.process_oob(None, "console", "<oob></oob>"))
Example #25
0
    def test_with_no_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        dynamic_config = BrainDynamicsConfiguration()
        dynamic_config.load_config_section(yaml, brain_config, ".")
Example #26
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        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?
            initial_question_srai: YINITIALQUESTION
            default_response: Sorry, I don't have an answer for that!
            default_response_srai: YDEFAULTRESPONSE
            empty_string: YEMPTY
            exit_response: So long, and thanks for the fish!
            exit_response_srai: YEXITRESPONSE
            override_properties: true
            max_question_recursion: 1000
            max_question_timeout: 60
            max_search_depth: 100
            max_search_timeout: 60
            spelling:
              classname: programy.spelling.norvig.NorvigSpellingChecker
              alphabet: 'abcdefghijklmnopqrstuvwxyz'
              corpus: $BOT_ROOT/corpus.txt
              check_before: true
              check_and_retry: true
        """, ConsoleConfiguration(), ".")

        bot_config = BotConfiguration()
        bot_config.load_configuration(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("YINITIALQUESTION", bot_config.initial_question_srai)
        self.assertEqual("Sorry, I don't have an answer for that!",
                         bot_config.default_response)
        self.assertEqual("YDEFAULTRESPONSE", bot_config.default_response_srai)
        self.assertEqual("So long, and thanks for the fish!",
                         bot_config.exit_response)
        self.assertEqual("YEXITRESPONSE", bot_config.exit_response_srai)
        self.assertEqual("YEMPTY", bot_config.empty_string)
        self.assertEqual(bot_config.max_question_recursion, 1000)
        self.assertEqual(bot_config.max_question_timeout, 60)
        self.assertEqual(bot_config.max_search_depth, 100)
        self.assertEqual(bot_config.max_search_timeout, 60)
        self.assertTrue(bot_config.override_properties)

        self.assertIsNotNone(bot_config.spelling)
        self.assertEqual("programy.spelling.norvig.NorvigSpellingChecker",
                         bot_config.spelling.classname)
Example #27
0
    def test_oob_loading(self):

        yaml = YamlConfigurationFile()
        yaml.load_from_file(os.path.dirname(__file__)+"/test_brain.yaml", ConsoleConfiguration(), os.path.dirname(__file__))

        brain_config = BrainConfiguration()
        brain_config.load_config_section(yaml, ".")

        brain = Brain(brain_config)

        self.assertIsInstance(brain.default_oob, DefaultOutOfBoundsProcessor)
        self.assertIsInstance(brain.oobs['dial'], DialOutOfBoundsProcessor)
        self.assertIsInstance(brain.oobs['email'], EmailOutOfBoundsProcessor)
Example #28
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        twilio:
        """, ConsoleConfiguration(), ".")

        twilio_config = TwilioConfiguration()
        twilio_config.load_configuration(yaml, ".")

        self.assertEqual("0.0.0.0", twilio_config.host)
        self.assertEqual(5001, twilio_config.port)
        self.assertEqual(False, twilio_config.debug)
Example #29
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        line:
        """, ConsoleConfiguration(), ".")

        line_config = LineConfiguration()
        line_config.load_configuration(yaml, ".")

        self.assertEqual("0.0.0.0", line_config.host)
        self.assertEqual(5000, line_config.port)
        self.assertEqual(False, line_config.debug)
Example #30
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        facebook:
        """, ConsoleConfiguration(), ".")

        facebook_config = FacebookConfiguration()
        facebook_config.load_configuration(yaml, ".")

        self.assertEqual("0.0.0.0", facebook_config.host)
        self.assertEqual(5000, facebook_config.port)
        self.assertEqual(False, facebook_config.debug)