Exemplo n.º 1
0
    def test_get_exit_response_exit_response_srai_no_match(self):

        brain_config = BrainConfiguration()
        self.assertIsNotNone(brain_config)
        test_brain = Brain(brain_config)
        self.assertIsNotNone(test_brain)
        bot_config = BotConfiguration()
        self.assertIsNotNone(bot_config)
        bot_config.exit_response_srai = "YDEFAULTRESPONSE"
        bot_config.exit_response = "Default response!"
        bot = Bot(test_brain, bot_config)
        self.assertIsNotNone(bot)

        self.assertEquals("Default response!", bot.get_exit_response("testid"))
Exemplo n.º 2
0
    def test_get_initial_question_initial_question_only(self):

        brain_config = BrainConfiguration()
        self.assertIsNotNone(brain_config)
        test_brain = Brain(brain_config)
        self.assertIsNotNone(test_brain)
        bot_config = BotConfiguration()
        self.assertIsNotNone(bot_config)
        bot_config.initial_question = "Default response!"
        bot = Bot(test_brain, bot_config)
        self.assertIsNotNone(bot)

        self.assertEquals("Default response!",
                          bot.get_initial_question("testid"))
Exemplo n.º 3
0
    def test_bot_init_blank(self):
        test_brain = Brain(BrainConfiguration())
        bot = Bot(test_brain, None)

        self.assertIsNone(bot.spell_checker)
        self.assertIsNotNone(bot.brain)
        self.assertIsNotNone(bot.conversations)
        self.assertIsNotNone(bot.license_keys)
        self.assertIsNotNone(bot.prompt)
        self.assertIsNotNone(bot.default_response)
        self.assertIsNotNone(bot.exit_response)
        self.assertIsNotNone(bot.initial_question)
        self.assertFalse(bot.override_properties)
        self.assertIsNotNone(bot.get_version_string)
Exemplo n.º 4
0
    def test_conversation(self):
        brain_config = BrainConfiguration()
        test_brain = Brain(brain_config)
        bot_config = BotConfiguration()
        bot_config.conversations._max_histories = 3
        test_bot = Bot(test_brain, bot_config)

        conversation = Conversation("test", test_bot)
        self.assertIsNotNone(conversation)
        self.assertIsNotNone(conversation._bot)
        self.assertIsNotNone(conversation._clientid)
        self.assertEqual(conversation._clientid, "test")
        self.assertEqual(0, len(conversation._questions))
        self.assertEqual(3, conversation._max_histories)
        self.assertEqual(1, len(conversation._properties))

        with self.assertRaises(Exception):
            conversation.current_question()
        with self.assertRaises(Exception):
            conversation.previous_nth_question(0)

        question1 = Question.create_from_text("Hello There")
        conversation.record_dialog(question1)
        self.assertEqual(question1, conversation.current_question())
        with self.assertRaises(Exception):
            conversation.previous_nth_question(1)

        question2 = Question.create_from_text("Hello There Again")
        conversation.record_dialog(question2)
        self.assertEqual(question2, conversation.current_question())
        self.assertEqual(question1, conversation.previous_nth_question(1))
        with self.assertRaises(Exception):
            conversation.previous_nth_question(3)

        question3 = Question.create_from_text("Hello There Again Again")
        conversation.record_dialog(question3)
        self.assertEqual(question3, conversation.current_question())
        self.assertEqual(question2, conversation.previous_nth_question(1))
        with self.assertRaises(Exception):
            conversation.previous_nth_question(4)

        # Max Histories for this test is 3
        # Therefore we should see the first question, pop of the stack

        question4 = Question.create_from_text("Hello There Again Again Again")
        conversation.record_dialog(question4)
        self.assertEqual(question4, conversation.current_question())
        self.assertEqual(question3, conversation.previous_nth_question(1))
        with self.assertRaises(Exception):
            conversation.previous_nth_question(5)
Exemplo n.º 5
0
    def test_oob_loading(self):

        yaml = YamlConfigurationFile()
        self.load_os_specific_configuration(yaml, "test_brain.yaml",
                                            "test_brain.windows.yaml")

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

        brain = Brain(brain_config)

        self.assertIsInstance(brain.default_oob, DefaultOutOfBandProcessor)
        self.assertIsInstance(brain.oobs['dial'], DialOutOfBandProcessor)
        self.assertIsInstance(brain.oobs['email'], EmailOutOfBandProcessor)
Exemplo n.º 6
0
    def __init__(self,
                 client_configuration,
                 brain_config=None,
                 bot_config=None):
        if brain_config is None:
            self._brain_config = BrainConfiguration()
        else:
            self._brain_config = brain_config

        if bot_config is None:
            self._bot_config = BotConfiguration()
        else:
            self._bot_config = bot_config

        self._client_config = client_configuration
Exemplo n.º 7
0
    def test_bot_chat_loop(self):

        test_brain = Brain(BrainConfiguration())
        self.assertIsNotNone(test_brain)
        self.assertIsInstance(test_brain, Brain)

        bot = Bot(test_brain, BotConfiguration())
        self.assertIsNotNone(bot)
        self.assertIsInstance(bot, Bot)
        bot.configuration._default_response = "Sorry, I don't have an answer for that right now"

        response = bot.ask_question("testid", "hello")
        self.assertIsNotNone(response)
        self.assertEqual(response,
                         "Sorry, I don't have an answer for that right now")

        response = bot.ask_question("testid", "hello again")
        self.assertIsNotNone(response)
        self.assertEqual(response,
                         "Sorry, I don't have an answer for that right now")

        response = bot.ask_question("testid", "goodbye")
        self.assertIsNotNone(response)
        self.assertEqual(response,
                         "Sorry, I don't have an answer for that right now")

        conversation = bot.get_conversation("testid")
        self.assertIsNotNone(conversation)

        self.assertEqual(
            conversation.previous_nth_question(2).sentence(0).text(), "hello")
        self.assertEqual(
            conversation.previous_nth_question(2).sentence(0).response,
            "Sorry, I don't have an answer for that right now")

        self.assertEqual(
            conversation.previous_nth_question(1).sentence(0).text(),
            "hello again")
        self.assertEqual(
            conversation.previous_nth_question(1).sentence(0).response,
            "Sorry, I don't have an answer for that right now")

        self.assertEqual(
            conversation.previous_nth_question(0).sentence(0).text(),
            "goodbye")
        self.assertEqual(
            conversation.previous_nth_question(0).sentence(0).response,
            "Sorry, I don't have an answer for that right now")
Exemplo n.º 8
0
    def test_get_initial_question_initial_question_srai_match(self):

        brain_config = BrainConfiguration()
        self.assertIsNotNone(brain_config)
        test_brain = MockBrain(brain_config)
        test_brain._response = "Y DEFAULT RESPONSE"
        self.assertIsNotNone(test_brain)
        bot_config = BotConfiguration()
        self.assertIsNotNone(bot_config)
        bot_config.initial_question_srai = "YDEFAULTRESPONSE"
        bot_config.initial_question = "Default response!"
        bot = Bot(test_brain, bot_config)
        self.assertIsNotNone(bot)

        self.assertEquals("Y DEFAULT RESPONSE",
                          bot.get_initial_question("testid"))
Exemplo n.º 9
0
    def test_brain_init_with_config(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.assertIsNotNone(brain)

        self.assertIsNotNone(brain.aiml_parser)
        self.assertIsNotNone(brain.denormals)
        self.assertIsNotNone(brain.normals)
        self.assertIsNotNone(brain.genders)
        self.assertIsNotNone(brain.persons)
        self.assertIsNotNone(brain.person2s)
        self.assertIsNotNone(brain.predicates)
        self.assertIsNotNone(brain.pronouns)
        self.assertIsNotNone(brain.properties)
        self.assertIsNotNone(brain.triples)
        self.assertIsNotNone(brain.sets)
        self.assertIsNotNone(brain.maps)
        self.assertIsNotNone(brain.preprocessors)
        self.assertIsNotNone(brain.postprocessors)
        self.assertIsNotNone(brain.authentication)
        self.assertIsNotNone(brain.authorisation)
        self.assertIsNotNone(brain.default_oob)
        self.assertIsNotNone(brain.oobs)

        if os.path.exists(brain_config.binaries.binary_filename):
            os.remove(brain_config.binaries.binary_filename)
        self.assertFalse(os.path.exists(brain_config.binaries.binary_filename))
        brain.save_binary(brain_config)
        self.assertTrue(os.path.exists(brain_config.binaries.binary_filename))
        brain.load_binary(brain_config)

        self.assertTrue(brain.authentication.authenticate("console"))
        self.assertTrue(brain.authentication.authenticate("someone"))

        self.assertTrue(brain.authorisation.authorise("console", "somthing"))
        self.assertTrue(brain.authorisation.authorise("someone", "other"))

        oob_content = ET.fromstring("<oob><something>other</something></oob>")
        self.assertEqual("", brain.default_oob.process_out_of_bounds(None, "console", oob_content))
        oob_content = ET.fromstring("<oob><dial>07777777777</dial></oob>")
        self.assertEqual("", brain.oobs['dial'].process_out_of_bounds(None, "console", oob_content))
Exemplo n.º 10
0
    def test_total_search_time(self):

        test_brain = Brain(BrainConfiguration())
        self.assertIsNotNone(test_brain)

        bot = Bot(test_brain, BotConfiguration())
        self.assertIsNotNone(bot)

        bot._question_start_time = datetime.datetime.now()
        self.assertTrue(bot.total_search_time() >= 0)

        bot.configuration._max_question_timeout = -1
        bot.check_max_timeout()

        bot.configuration._max_question_timeout = 0
        with self.assertRaises(Exception):
            bot.check_max_timeout()
Exemplo n.º 11
0
    def test_brain_init_with_config(self):

        yaml = YamlConfigurationFile()
        self.load_os_specific_configuration(yaml, "test_brain.yaml", "test_brain.windows.yaml")

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

        brain = Brain(brain_config)
        self.assertIsNotNone(brain)

        self.assertIsNotNone(brain.aiml_parser)
        self.assertIsNotNone(brain.denormals)
        self.assertIsNotNone(brain.normals)
        self.assertIsNotNone(brain.genders)
        self.assertIsNotNone(brain.persons)
        self.assertIsNotNone(brain.person2s)
        self.assertIsNotNone(brain.properties)
        self.assertIsNotNone(brain.rdf)
        self.assertIsNotNone(brain.sets)
        self.assertIsNotNone(brain.maps)
        self.assertIsNotNone(brain.preprocessors)
        self.assertIsNotNone(brain.postprocessors)
        self.assertIsNotNone(brain.authentication)
        self.assertIsNotNone(brain.authorisation)
        self.assertIsNotNone(brain.default_oob)
        self.assertIsNotNone(brain.oobs)

        if os.path.exists(brain_config.binaries.binary_filename):
            os.remove(brain_config.binaries.binary_filename)
        self.assertFalse(os.path.exists(brain_config.binaries.binary_filename))
        brain.save_binary(brain_config)
        self.assertTrue(os.path.exists(brain_config.binaries.binary_filename))
        brain.load_binary(brain_config)

        self.assertTrue(brain.authentication.authenticate("console"))
        self.assertTrue(brain.authentication.authenticate("someone"))

        self.assertTrue(brain.authorisation.authorise("console", "somthing"))
        self.assertTrue(brain.authorisation.authorise("someone", "other"))

        oob_content = ET.fromstring("<oob><something>other</something></oob>")
        self.assertEqual("<?xml version='1.0' encoding='utf8'?>\n<oob><something>other</something></oob>", brain.default_oob.process_out_of_bounds(None, "console", oob_content))
        oob_content = ET.fromstring("<oob><dial>07777777777</dial></oob>")
        self.assertEqual("", brain.oobs['dial'].process_out_of_bounds(None, "console", oob_content))
Exemplo n.º 12
0
    def test_call_service(self):

        service_config = BrainServiceConfiguration("mock")
        service_config._classname = 'programytest.services.test_service.MockService'

        brain_config = BrainConfiguration()
        brain_config.services._services['mock'] = service_config

        ServiceFactory.preload_services(brain_config.services)

        root = TemplateNode()

        node = TemplateSRAIXNode()
        node.service = "mock"
        root.append(node)
        node.append(TemplateWordNode("Hello"))

        self.assertEqual("asked", node.resolve(self.bot, self.clientid))
Exemplo n.º 13
0
    def test_brain_init_with_secure_config(self):

        yaml = YamlConfigurationFile()
        yaml.load_from_file(os.path.dirname(__file__)+ os.sep + "test_secure_brain.yaml", ConsoleConfiguration(), os.path.dirname(__file__))

        brain_config = BrainConfiguration()
        brain_config.load_config_section(yaml, os.path.dirname(__file__))

        brain = Brain(brain_config)
        self.assertIsNotNone(brain)

        self.assertTrue(brain.authentication.authenticate("console"))
        self.assertFalse(brain.authentication.authenticate("someone"))

        self.assertTrue(brain.authorisation.authorise("console", "root"))
        self.assertFalse(brain.authorisation.authorise("console", "unknown"))
        with self.assertRaises(AuthorisationException):
            brain.authorisation.authorise("someone", "root")
Exemplo n.º 14
0
    def test_brain_init_no_config(self):
        brain = Brain(BrainConfiguration())
        self.assertIsNotNone(brain)

        self.assertIsNotNone(brain.aiml_parser)
        self.assertIsNotNone(brain.denormals)
        self.assertIsNotNone(brain.normals)
        self.assertIsNotNone(brain.genders)
        self.assertIsNotNone(brain.persons)
        self.assertIsNotNone(brain.person2s)
        self.assertIsNotNone(brain.properties)
        self.assertIsNotNone(brain.rdf)
        self.assertIsNotNone(brain.sets)
        self.assertIsNotNone(brain.maps)
        self.assertIsNotNone(brain.preprocessors)
        self.assertIsNotNone(brain.postprocessors)
        self.assertIsNone(brain.default_oob)
        self.assertIsNotNone(brain.oobs)
Exemplo n.º 15
0
    def test_bot_init_with_spellchecker(self):
        test_brain = Brain(BrainConfiguration())
        bot_config = BotConfiguration()
        bot_config.spelling._classname = "programy.utils.spelling.checker.SpellingChecker"
        bot_config.spelling._corpus = os.path.dirname(__file__) + os.sep + "test_corpus.txt"
        bot_config.spelling._check_before = True
        bot_config.spelling._check_and_retry = True
        bot = Bot(test_brain, bot_config)
        self.assertIsNotNone(bot)

        test_sentence = Sentence("locetion")
        bot.check_spelling_before(test_sentence)
        self.assertIsNotNone(test_sentence)
        self.assertEqual("LOCATION", test_sentence.text())

        test_sentence = Sentence("locetion")
        response = bot.check_spelling_and_retry("testid", test_sentence)
        self.assertIsNone(None)
Exemplo n.º 16
0
    def test_match_sentence(self):

        self.parser.parse_from_text(
            """<?xml version="1.0" encoding="UTF-8"?>
            <aiml>
                <category>
                    <pattern>HELLO</pattern>
                    <template>Hiya</template>
                </category>
            </aiml>
            """)

        self.parser.pattern_parser.dump()

        bot = Bot(Brain(BrainConfiguration()), config=BotConfiguration())

        context = self.parser.match_sentence(bot, "test", Sentence("HELLO"), "*", "*")
        self.assertIsNotNone(context)
        self.assertEqual("Hiya", context.template_node().template.resolve(None, None))
Exemplo n.º 17
0
    def test_bot_with_config(self):
        configuration = ProgramyConfiguration(ConsoleConfiguration())
        self.assertIsNotNone(configuration)
        self.assertIsNotNone(configuration.bot_configuration)
        self.assertIsNotNone(configuration.brain_configuration)

        configuration.bot_configuration.prompt = ":"
        configuration.bot_configuration.default_response = "No answer for that"
        configuration.bot_configuration.exit_response = "See ya!"

        test_brain = Brain(BrainConfiguration())
        test_brain.load(configuration.brain_configuration)

        bot = Bot(test_brain, config=configuration.bot_configuration)
        self.assertIsNotNone(bot)

        self.assertEqual(bot.prompt, ":")
        self.assertEqual(bot.default_response, "No answer for that")
        self.assertEqual(bot.exit_response, "See ya!")
Exemplo n.º 18
0
    def test_bot_with_conversation(self):
        test_brain = Brain(BrainConfiguration())
        self.assertIsNotNone(test_brain)

        bot = Bot(test_brain, BotConfiguration())
        self.assertIsNotNone(bot)

        self.assertFalse(bot.has_conversation("testid"))

        response = bot.ask_question("testid", "hello")
        self.assertIsNotNone(response)
        self.assertTrue(bot.has_conversation("testid"))

        response = bot.ask_question("testid", "hello")
        self.assertIsNotNone(response)
        self.assertTrue(bot.has_conversation("testid"))

        response = bot.ask_question("testid2", "hello")
        self.assertIsNotNone(response)
        self.assertTrue(bot.has_conversation("testid2"))
Exemplo n.º 19
0
    def test_oob_stripping(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)

        response, oob = brain.strip_oob("<oob>command</oob>")
        self.assertEqual("", response)
        self.assertEqual("<oob>command</oob>", oob)

        response, oob = brain.strip_oob("This <oob>command</oob>")
        self.assertEqual("This ", response)
        self.assertEqual("<oob>command</oob>", oob)

        response, oob = brain.strip_oob("This <oob>command</oob> That")
        self.assertEqual("This That", response)
        self.assertEqual("<oob>command</oob>", oob)
Exemplo n.º 20
0
    def test_oob_stripping(self):

        yaml = YamlConfigurationFile()
        self.load_os_specific_configuration(yaml, "test_brain.yaml", "test_brain.windows.yaml")

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

        brain = Brain(brain_config)

        response, oob = brain.strip_oob("<oob>command</oob>")
        self.assertEqual("", response)
        self.assertEqual("<oob>command</oob>", oob)

        response, oob = brain.strip_oob("This <oob>command</oob>")
        self.assertEqual("This ", response)
        self.assertEqual("<oob>command</oob>", oob)

        response, oob = brain.strip_oob("This <oob>command</oob> That")
        self.assertEqual("This That", response)
        self.assertEqual("<oob>command</oob>", oob)
Exemplo n.º 21
0
 def setUp(self):
     self.bot = Bot(Brain(BrainConfiguration()), config=BotConfiguration())
Exemplo n.º 22
0
    def test_with_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
            brain:
                overrides:
                  allow_system_aiml: true
                  allow_learn_aiml: true
                  allow_learnf_aiml: true
            
                defaults:
                  default-get: unknown
                  default-property: unknown
                  default-map: unknown
                  learn-filename: y-bot-learn.aiml

                nodes:
                  pattern_nodes: $BOT_ROOT/config/pattern_nodes.conf
                  template_nodes: $BOT_ROOT/config/template_nodes.conf
            
                binaries:
                  save_binary: false
                  load_binary: false
                  binary_filename: /tmp/y-bot.brain
                  load_aiml_on_binary_fail: false

                braintree:
                  file: /tmp/braintree.xml
                  content: xml
            
                files:
                    aiml:
                        files: $BOT_ROOT/aiml
                        extension: .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/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
                    properties: $BOT_ROOT/config/properties.txt
                    triples: $BOT_ROOT/config/triples.txt
                    preprocessors: $BOT_ROOT/config/preprocessors.conf
                    postprocessors: $BOT_ROOT/config/postprocessors.conf
                    regex_templates: $BOT_ROOT/config/regex-templates.txt
            
                security:
                    authentication:
                        classname: programy.utils.security.authenticate.passthrough.PassThroughAuthenticationService
                        denied_srai: AUTHENTICATION_FAILED
                    authorisation:
                        classname: programy.utils.security.authorise.passthrough.PassThroughAuthorisationService
                        denied_srai: AUTHORISATION_FAILED

                oob:
                  default:
                    classname: programy.utils.oob.default.DefaultOutOfBandProcessor
                  dial:
                    classname: programy.utils.oob.dial.DialOutOfBandProcessor
                  email:
                    classname: programy.utils.oob.email.EmailOutOfBandProcessor

                dynamic:
                    variables:
                        gettime: programy.dynamic.variables.datetime.GetTime
                    sets:
                        number: programy.dynamic.sets.numeric.IsNumeric
                        roman:   programy.dynamic.sets.roman.IsRomanNumeral
                    maps:
                        romantodec: programy.dynamic.maps.roman.MapRomanToDecimal
                        dectoroman: programy.dynamic.maps.roman.MapDecimalToRoman

                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 = BrainConfiguration()
        brain_config.load_config_section(yaml, ".")

        self.assertIsNotNone(brain_config.overrides)
        self.assertTrue(brain_config.overrides.allow_system_aiml)
        self.assertTrue(brain_config.overrides.allow_learn_aiml)
        self.assertTrue(brain_config.overrides.allow_learnf_aiml)

        self.assertIsNotNone(brain_config.defaults)
        self.assertEqual("unknown", brain_config.defaults.default_get)
        self.assertEqual("unknown", brain_config.defaults.default_property)
        self.assertEqual("unknown", brain_config.defaults.default_map)
        self.assertEqual("y-bot-learn.aiml",
                         brain_config.defaults.learn_filename)

        self.assertIsNotNone(brain_config.nodes)
        self.assertEquals("./config/pattern_nodes.conf",
                          brain_config.nodes.pattern_nodes)
        self.assertEquals("./config/template_nodes.conf",
                          brain_config.nodes.template_nodes)

        self.assertIsNotNone(brain_config.binaries)
        self.assertFalse(brain_config.binaries.save_binary)
        self.assertFalse(brain_config.binaries.load_binary)
        self.assertEquals("/tmp/y-bot.brain",
                          brain_config.binaries.binary_filename)
        self.assertFalse(brain_config.binaries.load_aiml_on_binary_fail)

        self.assertIsNotNone(brain_config.braintree)
        self.assertEquals("/tmp/braintree.xml", brain_config.braintree.file)
        self.assertEquals("xml", brain_config.braintree.content)

        self.assertIsNotNone(brain_config.files)
        self.assertIsNotNone(brain_config.files.aiml_files)
        self.assertEqual("./aiml", brain_config.files.aiml_files.files)
        self.assertEqual(".aiml", brain_config.files.aiml_files.extension)
        self.assertTrue(brain_config.files.aiml_files.directories)
        self.assertEqual("/tmp/y-bot_errors.txt",
                         brain_config.files.aiml_files.errors)
        self.assertEqual("/tmp/y-bot_duplicates.txt",
                         brain_config.files.aiml_files.duplicates)
        self.assertEqual("/tmp/y-bot_conversation.txt",
                         brain_config.files.aiml_files.conversation)

        self.assertIsNotNone(brain_config.files.set_files)
        self.assertEqual("./sets", brain_config.files.set_files.files)
        self.assertEqual(".txt", brain_config.files.set_files.extension)
        self.assertFalse(brain_config.files.set_files.directories)

        self.assertIsNotNone(brain_config.files.map_files)
        self.assertEqual("./maps", brain_config.files.map_files.files)
        self.assertEqual(".txt", brain_config.files.map_files.extension)
        self.assertFalse(brain_config.files.map_files.directories)

        self.assertEqual(brain_config.files.denormal, "./config/denormal.txt")
        self.assertEqual(brain_config.files.normal, "./config/normal.txt")
        self.assertEqual(brain_config.files.gender, "./config/gender.txt")
        self.assertEqual(brain_config.files.person, "./config/person.txt")
        self.assertEqual(brain_config.files.person2, "./config/person2.txt")
        self.assertEqual(brain_config.files.properties,
                         "./config/properties.txt")
        self.assertEqual(brain_config.files.triples, "./config/triples.txt")
        self.assertEqual(brain_config.files.preprocessors,
                         "./config/preprocessors.conf")
        self.assertEqual(brain_config.files.postprocessors,
                         "./config/postprocessors.conf")
        self.assertEqual(brain_config.files.regex_templates,
                         "./config/regex-templates.txt")

        self.assertIsNotNone(brain_config.security)
        self.assertIsNotNone(brain_config.security.authorisation)
        self.assertIsNotNone(brain_config.security.authentication)

        self.assertIsNotNone(brain_config.services)
        self.assertTrue(brain_config.services.exists("REST"))
        self.assertTrue(brain_config.services.exists("Pannous"))
        self.assertTrue(brain_config.services.exists("Pandora"))
        self.assertTrue(brain_config.services.exists("Wikipedia"))
        self.assertFalse(brain_config.services.exists("Other"))

        self.assertIsNotNone(brain_config.oob)
        self.assertIsNotNone(brain_config.oob.oobs())
        self.assertIsNotNone(brain_config.oob.default())
        self.assertIsNotNone(brain_config.oob.oob("dial"))
        self.assertIsNotNone(brain_config.oob.oob("email"))

        self.assertIsNotNone(brain_config.dynamics)
        self.assertIsNotNone(brain_config.dynamics.dynamic_sets)
        self.assertTrue("NUMBER" in brain_config.dynamics.dynamic_sets)
        self.assertTrue("ROMAN" in brain_config.dynamics.dynamic_sets)
        self.assertIsNotNone(brain_config.dynamics.dynamic_maps)
        self.assertTrue("ROMANTODEC" in brain_config.dynamics.dynamic_maps)
        self.assertTrue("DECTOROMAN" in brain_config.dynamics.dynamic_maps)
        self.assertIsNotNone(brain_config.dynamics.dynamic_vars)
        self.assertTrue("GETTIME" in brain_config.dynamics.dynamic_vars)
Exemplo n.º 23
0
 def get_brain_config(self):
     return BrainConfiguration()
Exemplo n.º 24
0
 def test_bot_init_supplied_brain(self):
     test_brain = Brain(BrainConfiguration())
     bot = Bot(test_brain, BotConfiguration())
     self.assertIsNotNone(bot)
     self.assertIsNotNone(bot.brain)
Exemplo n.º 25
0
 def test_bot_init_no_license_keys(self):
     test_brain = Brain(BrainConfiguration())
     bot_config = BotConfiguration()
     bot_config._license_keys = None
     bot = Bot(test_brain, bot_config)
     self.assertIsNotNone(bot)
Exemplo n.º 26
0
 def test_bot_init_with_invalid_spellchecker(self):
     test_brain = Brain(BrainConfiguration())
     bot_config = BotConfiguration()
     bot_config.spelling._classname = "programy.utils.spelling.checker.SpellingCheckerX"
     bot = Bot(test_brain, bot_config)
     self.assertIsNotNone(bot)
Exemplo n.º 27
0
 def test_bot_init_no_spellchecker(self):
     test_brain = Brain(BrainConfiguration())
     bot_config = BotConfiguration()
     bot_config.spelling._classname = None
     bot = Bot(test_brain, bot_config)
     self.assertIsNotNone(bot)
Exemplo n.º 28
0
 def setUp(self):
     self._clientid = "testid"
     self._brain = Brain(BrainConfiguration())
     self._bot = Bot(self._brain, BotConfiguration())
     self._aiml_parser = AIMLParser(self._brain)
Exemplo n.º 29
0
 def test_bot_init_with_license_keys(self):
     test_brain = Brain(BrainConfiguration())
     bot_config = BotConfiguration()
     bot_config._license_keys = os.path.dirname(__file__) + os.sep + "test_license.keys"
     bot = Bot(test_brain, bot_config)
     self.assertIsNotNone(bot)
Exemplo n.º 30
0
 def setUp(self):
     self.bot = Bot(Brain(BrainConfiguration()), config=BotConfiguration())
     self.bot.brain.denormals.process_splits([" dot com ",".com"])