Ejemplo n.º 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)
Ejemplo n.º 2
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertIsNotNone(config.configurations)
        self.assertEquals(1, len(config.configurations))
Ejemplo n.º 3
0
    def test_to_yaml_with_defaults(self):
        config = ConsoleConfiguration()

        data = {}
        config.to_yaml(data, True)

        self.assertEquals('console', data['default_userid'])
        self.assertEquals('>>>', data['prompt'])

        self.assertEquals(data['bot'], 'bot')
        self.assertEquals(data['license_keys'], "./config/license.keys")
        self.assertEquals(data['bot_selector'],
                          "programr.clients.client.DefaultBotSelector")
        self.assertEquals(data['renderer'],
                          "programr.clients.render.text.TextRenderer")
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
            twitter:
              polling_interval: 59
              rate_limit_sleep: 900
              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_configuration(yaml, ".")

        self.assertEqual(59, twitter_config.polling_interval)
        self.assertEqual(900, twitter_config.rate_limit_sleep)
        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)
Ejemplo n.º 8
0
    def test_load_from_text_single_files(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        configuration = yaml.load_from_text("""
            brain:

                files:
                    aiml:
                        files: $BOT_ROOT/test-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.client_configuration.brain_config[0].brain_config[0].files.aiml_files.has_multiple_files())
        self.assertFalse(configuration.client_configuration.brain_config[0].brain_config[0].files.aiml_files.has_single_file())

        self.assertEqual(configuration.client_configuration.brain_config[0].brain_config[0].files.aiml_files.files, ["./test-aiml"])
        self.assertEqual(configuration.client_configuration.brain_config[0].brain_config[0].files.set_files.files, ["./test-sets"])
        self.assertEqual(configuration.client_configuration.brain_config[0].brain_config[0].files.map_files.files, ["./test-maps"])
Ejemplo n.º 9
0
    def test_rest_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                REST:
                    classname: programr.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("programr.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)
Ejemplo n.º 10
0
    def test_wikipedia_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                Wikipedia:
                    classname: programr.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("programr.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)
Ejemplo n.º 11
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        kik:
          bot_name: testbot
          webhook: https://localhost:5000
          host: 127.0.0.1
          port: 5000
          debug: false
          unknown_command: Sorry, that is not a command I have been taught yet!
          unknown_command_srai: YKIK_UNKNOWN_COMMAND
        """, ConsoleConfiguration(), ".")

        kik_config = KikConfiguration()
        kik_config.load_configuration(yaml, ".")

        self.assertEqual("testbot", kik_config.bot_name)
        self.assertEqual("https://localhost:5000", kik_config.webhook)
        self.assertEqual("127.0.0.1", kik_config.host)
        self.assertEqual(5000, kik_config.port)
        self.assertEqual(False, kik_config.debug)
        self.assertEquals(
            kik_config.unknown_command,
            "Sorry, that is not a command I have been taught yet!")
        self.assertEquals(kik_config.unknown_command_srai,
                          "YKIK_UNKNOWN_COMMAND")
Ejemplo n.º 12
0
    def test_pandora_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            services:
                Pandora:
                    classname: programr.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("programr.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)
Ejemplo n.º 13
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        brain:
            services:
                REST:
                    classname: programr.services.rest.GenericRESTService
                    method: GET
                    host: 0.0.0.0
                Pannous:
                    classname: programr.services.pannous.PannousService
                    url: http://weannie.pannous.com/api
                Pandora:
                    classname: programr.services.pandora.PandoraService
                    url: http://www.pandorabots.com/pandora/talk-xml
                Wikipedia:
                    classname: programr.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"))
Ejemplo n.º 14
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        bot:
            spelling:
              classname: programr.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("programr.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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          scheduler:
            name: Scheduler1
            debug_level: 0
            add_listeners: True
            remove_all_jobs: True
            
            jobstore:
                name:   mongo
                
                mongo:
                    collection: example_jobs
    
                redis:
                    jobs_key: example.jobs
                    run_times_key: example.run_times
    
                sqlalchemy:
                    url: sqlite:///jobs.sqlite
    
            threadpool:
                max_workers: 20
        
            processpool:
                max_workers: 5   
        
            job_defaults:
                coalesce: False
                max_instances: 3
          
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("console")

        scheduler_config = SchedulerConfiguration()
        scheduler_config.load_config_section(yaml, bot_config, ".")

        self.assertEquals("Scheduler1", scheduler_config.name)
        self.assertEquals(0, scheduler_config.debug_level)
        self.assertTrue(scheduler_config.add_listeners)
        self.assertTrue(scheduler_config.remove_all_jobs)

        self.assertIsNotNone(scheduler_config.jobstore)
        self.assertIsNotNone(scheduler_config.jobstore.jobstore)
        self.assertEquals("example_jobs", scheduler_config.jobstore.jobstore.collection)

        self.assertIsNotNone(scheduler_config.threadpool)
        self.assertEquals(20, scheduler_config.threadpool.max_workers)

        self.assertIsNotNone(scheduler_config.processpool)
        self.assertEquals(5, scheduler_config.processpool.max_workers)

        self.assertIsNotNone(scheduler_config.job_defaults)
        self.assertEquals(False, scheduler_config.job_defaults.coalesce)
        self.assertEquals(3, scheduler_config.job_defaults.max_instances)
Ejemplo n.º 17
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)
Ejemplo n.º 18
0
 def test_load_from_file(self):
     xml = XMLConfigurationFile()
     self.assertIsNotNone(xml)
     configuration = xml.load_from_file(
         os.path.dirname(__file__) + os.sep + "test_xml.xml",
         ConsoleConfiguration(), ".")
     self.assertIsNotNone(configuration)
     self.assert_configuration(configuration)
Ejemplo n.º 19
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        bot:
            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: programr.spelling.norvig.NorvigSpellingChecker
              alphabet: 'abcdefghijklmnopqrstuvwxyz'
              corpus: $BOT_ROOT/corpus.txt
              check_before: true
              check_and_retry: true
              
            conversations:
              type: file
              config_name: file_storage
        
            file_storage:
              dir: $BOT_ROOT/conversations

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

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

        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("programr.spelling.norvig.NorvigSpellingChecker", bot_config.spelling.classname)

        self.assertIsNotNone(bot_config.conversations)
        self.assertEquals(bot_config.conversations.type, "file")
        self.assertIsNotNone(bot_config.conversations.storage)
        self.assertEquals(bot_config.conversations.storage.dir, "./conversations")
Ejemplo n.º 20
0
    def test_to_yaml_without_defaults(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        console:
          bot: bot
          default_userid: console
          prompt: $
          license_keys: ./config/license.keys
          bot_selector: programr.clients.client.DefaultBotSelector
          renderer: programr.clients.render.text.TextRenderer
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        data = {}
        config.to_yaml(data, False)

        self.assertEquals('console', data['default_userid'])
        self.assertEquals('$', data['prompt'])

        self.assertEquals(data['bot'], 'bot')
        self.assertEquals(data['license_keys'], "./config/license.keys")
        self.assertEquals(data['bot_selector'],
                          "programr.clients.client.DefaultBotSelector")
        self.assertEquals(data['renderer'],
                          "programr.clients.render.text.TextRenderer")
Ejemplo n.º 21
0
    def test_load_from_text_multis_one_value(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        configuration = yaml.load_from_text("""
            bot:
                brain:  bot1
        """, ConsoleConfiguration(), ".")
        self.assertIsNotNone(configuration)

        self.assertEquals(1, len(configuration.client_configuration.brain_config[0].brain_config))
Ejemplo n.º 22
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, ".")
Ejemplo n.º 23
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        console:
          bot: bot
          default_userid: console
          prompt: $
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertEquals("console", config.default_userid)
        self.assertEquals("$", config.prompt)

        self.assertIsNotNone(config.configurations)
        self.assertEquals(1, len(config.configurations))
        self.assertIsInstance(config.configurations[0], BotConfiguration)
Ejemplo n.º 24
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(80, facebook_config.port)
        self.assertEqual(False, facebook_config.debug)
Ejemplo n.º 25
0
    def test_without_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        brain:
            tokenizer:
        """, ConsoleConfiguration(), ".")

        brain_config = yaml.get_section("brain")

        tokenizer_config = BrainTokenizerConfiguration()
        tokenizer_config.load_config_section(yaml, brain_config, ".")
Ejemplo n.º 26
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(80, twilio_config.port)
        self.assertEqual(False, twilio_config.debug)
Ejemplo n.º 27
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
            slack:
              polling_interval: 1
        """, ConsoleConfiguration(), ".")

        slack_config = SlackConfiguration()
        slack_config.load_configuration(yaml, ".")

        self.assertEqual(1, slack_config.polling_interval)
Ejemplo n.º 28
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(80, line_config.port)
        self.assertEqual(False, line_config.debug)
Ejemplo n.º 29
0
    def test_get_methods(self):
        config_data = JSONConfigurationFile()
        self.assertIsNotNone(config_data)
        configuration = config_data.load_from_text(
            """
        {
        	"brain": {
        		"overrides": {
        			"allow_system_aiml": true,
        			"allow_learn_aiml": true,
        			"allow_learnf_aiml": true,
        			"int_value": 999
        		}
        	}
        }
         """, ConsoleConfiguration(), ".")
        self.assertIsNotNone(configuration)

        section = config_data.get_section("brainx")
        self.assertIsNone(section)

        section = config_data.get_section("brain")
        self.assertIsNotNone(section)

        child_section = config_data.get_section("overrides", section)
        self.assertIsNotNone(child_section)

        keys = list(config_data.get_child_section_keys("overrides", section))
        self.assertIsNotNone(keys)
        self.assertEqual(4, len(keys))
        self.assertTrue("allow_system_aiml" in keys)
        self.assertTrue("allow_learn_aiml" in keys)
        self.assertTrue("allow_learnf_aiml" in keys)
        self.assertIsNone(
            config_data.get_child_section_keys("missing", section))
        self.assertEqual(
            True, config_data.get_option(child_section, "allow_system_aiml"))
        self.assertEqual(
            True,
            config_data.get_option(child_section,
                                   "missing",
                                   missing_value=True))
        self.assertEqual(
            True,
            config_data.get_bool_option(child_section, "allow_system_aiml"))
        self.assertEqual(
            False, config_data.get_bool_option(child_section, "other_value"))
        self.assertEqual(
            999, config_data.get_int_option(child_section, "int_value"))
        self.assertEqual(
            0, config_data.get_int_option(child_section, "other_value"))
Ejemplo n.º 30
0
    def test_without_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        bot:
        """, ConsoleConfiguration(), ".")

        bot_config = yaml.get_section("bot")

        convo_config = BotConversationsFileStorageConfiguration(
            config_name="file_storage")
        convo_config.load_config_section(yaml, bot_config, ".")

        self.assertIsNone(convo_config.dir)