Ejemplo n.º 1
0
    def test_reload_person2(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.person2 = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "person2_1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.person2s)
        self.assertTrue(client_context.brain.person2s.has_key(" I WAS "))
        self.assertFalse(client_context.brain.person2s.has_key(" SHE WAS "))

        lookups_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.PERSON2)
        lookups_store = lookups_engine.person2_store()
        lookups_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "person2_2.txt"
        ]

        result = extension.execute(client_context, "RELOAD PERSON2")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.person2s)
        self.assertTrue(client_context.brain.person2s.has_key(" SHE WAS "))
        self.assertFalse(client_context.brain.person2s.has_key(" I WAS "))
Ejemplo n.º 2
0
    def test_reload_defaults(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.defaults = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "defaults1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.default_variables)
        self.assertTrue(
            client_context.brain.default_variables.has_property("name"))
        self.assertEqual(
            "Y-Bot", client_context.brain.default_variables.property("name"))

        default_variables_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.DEFAULTS)
        default_variables_store = default_variables_engine.defaults_store()
        default_variables_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "defaults2.txt"
        ]

        result = extension.execute(client_context, "RELOAD DEFAULTS")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.default_variables)
        self.assertTrue(
            client_context.brain.default_variables.has_property("name"))
        self.assertEqual(
            "Y-Bot2", client_context.brain.default_variables.property("name"))
Ejemplo n.º 3
0
    def test_reload_properties(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.properties = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "properties1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.properties)
        self.assertTrue(client_context.brain.properties.has_property("name"))
        self.assertEqual("Y-Bot",
                         client_context.brain.properties.property("name"))

        lookups_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.PROPERTIES)
        lookups_store = lookups_engine.property_store()
        lookups_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "properties2.txt"
        ]

        result = extension.execute(client_context, "RELOAD PROPERTIES")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.properties)
        self.assertTrue(client_context.brain.properties.has_property("name"))
        self.assertEqual("Y-Bot2",
                         client_context.brain.properties.property("name"))
Ejemplo n.º 4
0
    def test_reload_regex(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.regex_templates = os.path.dirname(
            __file__
        ) + os.sep + "test_config" + os.sep + "regex-templates1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.regex_templates)
        self.assertIsNotNone(
            client_context.brain.regex_templates.has_regex("anything"))
        self.assertEqual(
            re.compile('^.*$', re.IGNORECASE),
            client_context.brain.regex_templates.regex("anything"))

        regex_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.REGEX_TEMPLATES)
        regex_store = regex_engine.regex_store()
        regex_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "regex-templates2.txt"
        ]

        result = extension.execute(client_context, "RELOAD REGEX")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.regex_templates)
        self.assertIsNotNone(
            client_context.brain.regex_templates.has_regex("anything"))
        self.assertEqual(
            re.compile('^.2*$', re.IGNORECASE),
            client_context.brain.regex_templates.regex("anything"))
Ejemplo n.º 5
0
    def test_reload_patterns(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.pattern_nodes = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "pattern_nodes1.conf"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertTrue(
            client_context.brain.aiml_parser.pattern_parser._pattern_factory.
            exists("word"))

        lookups_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.PATTERN_NODES)
        lookups_store = lookups_engine.pattern_nodes_store()
        lookups_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "pattern_nodes2.conf"
        ]

        result = extension.execute(client_context, "RELOAD PATTERNS")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertFalse(
            client_context.brain.aiml_parser.pattern_parser._pattern_factory.
            exists("word"))
        self.assertTrue(
            client_context.brain.aiml_parser.pattern_parser._pattern_factory.
            exists("word2"))
Ejemplo n.º 6
0
    def test_reload_gender(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.gender = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "gender1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.genders)
        self.assertTrue(client_context.brain.genders.has_key(" WITH HIM "))
        self.assertFalse(client_context.brain.genders.has_key(" TO HIM "))

        lookups_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.GENDER)
        lookups_store = lookups_engine.gender_store()
        lookups_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "gender2.txt"
        ]

        result = extension.execute(client_context, "RELOAD GENDER")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.genders)
        self.assertTrue(client_context.brain.genders.has_key(" TO HIM "))
        self.assertFalse(client_context.brain.genders.has_key(" TO YOU "))
Ejemplo n.º 7
0
    def test_reload_normal(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.normal = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "normal1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.normals)
        self.assertTrue(client_context.brain.normals.has_key("%20"))
        self.assertFalse(client_context.brain.normals.has_key("%2C"))

        lookups_engine = client.storage_factory.entity_storage_engine(
            StorageFactory.NORMAL)
        lookups_store = lookups_engine.normal_store()
        lookups_store.get_storage()._dirs = [
            os.path.dirname(__file__) + os.sep + "test_config" + os.sep +
            "normal2.txt"
        ]

        result = extension.execute(client_context, "RELOAD NORMAL")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.normals)
        self.assertTrue(client_context.brain.normals.has_key("%2C"))
        self.assertFalse(client_context.brain.normals.has_key("%20"))
Ejemplo n.º 8
0
    def test_reload_all(self):
        extension = HotReloadAdminExtension()

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        result = extension.execute(client_context, "RELOAD ALL")
        self.assertEquals("HOTRELOAD OK", result)
Ejemplo n.º 9
0
    def test_reload_all(self):
        extension = HotReloadAdminExtension()

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        result = extension.execute(client_context, "RELOAD ALL")
        self.assertEqual("HOTRELOAD OK", result)
Ejemplo n.º 10
0
    def test_reload_all_other(self):
        extension = HotReloadAdminExtension()

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        result = extension.execute(client_context, "RELOAD ALL OTHER")
        self.assertEqual("Unknown RELOAD ALL entity [OTHER]", result)
Ejemplo n.º 11
0
    def test_reload_other(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.denormal = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "denormal1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        result = extension.execute(client_context, "RELOAD XXX")
        self.assertEquals("Unknown RELOAD entity [XXX]", result)
Ejemplo n.º 12
0
def upload_file():
    if request.method == 'POST':

        # INICIO DELETE FILES

        path = os.path.join(app.config['CATEGORIES_FOLDER'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(
                        os.path.join(app.config['CATEGORIES_FOLDER'], arquivo))

        path = os.path.join(app.config['BPMN_FILES'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(os.path.join(app.config['BPMN_FILES'], arquivo))

        path = os.path.join(app.config['BPMN_SIMPLIFIED'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(
                        os.path.join(app.config['BPMN_SIMPLIFIED'], arquivo))

        path = os.path.join(app.config['BPMN_FINITE_STATE'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(
                        os.path.join(app.config['BPMN_FINITE_STATE'], arquivo))

        # FIM DELETE FILES

        f = request.files['file']
        filename = secure_filename(f.filename)
        f.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

        converter_bpmn_aiml(os.path.join(app.config['UPLOAD_FOLDER'],
                                         filename))

        userid = WEB_CLIENT.get_userid(request)
        client_context = WEB_CLIENT.create_client_context(userid)
        HotReloadAdminExtension.reload_all(client_context)

        return '''<html><body><h2>BPMN file loaded sucessfully.</h2>
Ejemplo n.º 13
0
    def test_reload_rdf_invalid(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.rdf_files = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "rdfs1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertTrue(client_context.brain.rdf.has_subject('ANTEATER'))
        client_context.brain.rdf.delete_entity('ANTEATER')
        self.assertFalse(client_context.brain.rdf.has_subject('ANTEATER'))

        result = extension.execute(client_context, "RELOAD RDF ANIMALLEGS")
        self.assertEqual("HOTRELOAD OK", result)
Ejemplo n.º 14
0
    def test_reload_rdf(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.rdf_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "rdfs1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertTrue(client_context.brain.rdf.has_subject('ANTEATER'))
        client_context.brain.rdf.delete_entity('ANTEATER')
        self.assertFalse(client_context.brain.rdf.has_subject('ANTEATER'))

        result = extension.execute(client_context, "RELOAD RDF ANIMAL")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertTrue(client_context.brain.rdf.has_subject('ANTEATER'))
Ejemplo n.º 15
0
    def test_reload_templates(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.template_nodes = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "pattern_nodes1.conf"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertTrue(client_context.brain.aiml_parser.pattern_parser._pattern_factory.exists("word"))

        client_context.brain.aiml_parser.brain.configuration.nodes._pattern_nodes = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "pattern_nodes2.conf"

        result = extension.execute(client_context, "RELOAD PATTERNS")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertFalse(client_context.brain.aiml_parser.pattern_parser._pattern_factory.exists("word"))
        self.assertTrue(client_context.brain.aiml_parser.pattern_parser._pattern_factory.exists("word2"))
Ejemplo n.º 16
0
    def test_reload_aimls(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.aiml_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + 'aimls1'

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertEquals("That was test 1", client_context.bot.ask_question(client_context, "TEST1"))
        self.assertEquals("That was test 2", client_context.bot.ask_question(client_context, "TEST2"))

        client_context.client.configuration.client_configuration.configurations[0].configurations[0].files._aiml_files._files = [os.path.dirname(__file__) + os.sep + "test_config" + os.sep + 'aimls2']

        result = extension.execute(client_context, "RELOAD ALL AIML")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertEquals("That was test 3", client_context.bot.ask_question(client_context, "TEST3"))
        self.assertEquals("That was test 4", client_context.bot.ask_question(client_context, "TEST4"))
Ejemplo n.º 17
0
    def test_reload_set_invalid(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.set_files = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "sets1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.sets)
        self.assertTrue(client_context.brain.sets.contains("animal"))
        set = client_context.brain.sets.set_list("animal")
        self.assertTrue('BUFFALO' in set)
        del set['BUFFALO']
        self.assertFalse('BUFFALO' in set)

        result = extension.execute(client_context, "RELOAD SET ANIMALLEGS")
        self.assertEqual("HOTRELOAD OK", result)
Ejemplo n.º 18
0
    def test_reload_map_invalid(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.map_files = os.path.dirname(
            __file__) + os.sep + "test_config" + os.sep + "maps1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.maps)
        self.assertTrue(client_context.brain.maps.contains("animallegs"))
        al_map = client_context.brain.maps.map("animallegs")
        self.assertIsNotNone(al_map)
        self.assertEqual('4', al_map['BUFFALO'])
        al_map['BUFFALO'] = '6'
        self.assertEqual('6', al_map['BUFFALO'])

        result = extension.execute(client_context, "RELOAD MAP ANIMALS")
        self.assertEqual("HOTRELOAD OK", result)
Ejemplo n.º 19
0
    def test_reload_normal(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.normal = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "normal1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.normals)
        self.assertTrue(client_context.brain.normals.has_key("%20"))
        self.assertFalse(client_context.brain.normals.has_key("%2C"))

        client_context.brain.configuration.files._normal = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "normal2.txt"

        result = extension.execute(client_context, "RELOAD NORMAL")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.normals)
        self.assertTrue(client_context.brain.normals.has_key("%2C"))
        self.assertFalse(client_context.brain.normals.has_key("%20"))
Ejemplo n.º 20
0
    def test_reload_person2(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.person2 = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "person2_1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.person2s)
        self.assertTrue(client_context.brain.person2s.has_key(" I was "))
        self.assertFalse(client_context.brain.person2s.has_key(" she was "))

        client_context.brain.configuration.files._person2 = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "person2_2.txt"

        result = extension.execute(client_context, "RELOAD PERSON2")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.person2s)
        self.assertTrue(client_context.brain.person2s.has_key(" she was "))
        self.assertFalse(client_context.brain.person2s.has_key(" I was "))
Ejemplo n.º 21
0
    def test_reload_defaults(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.variables = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "variables1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.variables)
        self.assertTrue(client_context.brain.variables.has_property("name"))
        self.assertEquals("Y-Bot", client_context.brain.variables.property("name"))

        client_context.brain.configuration.files._variables = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "variables2.txt"

        result = extension.execute(client_context, "RELOAD DEFAULTS")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.variables)
        self.assertTrue(client_context.brain.variables.has_property("name"))
        self.assertEquals("Y-Bot2", client_context.brain.variables.property("name"))
Ejemplo n.º 22
0
    def test_reload_regex(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.regex_templates = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "regex-templates1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.regex_templates)
        self.assertIsNotNone(client_context.brain.regex_templates["anything"])
        self.assertEquals(re.compile('^.*$', re.IGNORECASE), client_context.brain.regex_templates["anything"])

        client_context.brain.configuration.files._regex_templates = os.path.dirname(__file__) + os.sep + "test_config" + os.sep +  "regex-templates2.txt"

        result = extension.execute(client_context, "RELOAD REGEX")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.regex_templates)
        self.assertIsNotNone(client_context.brain.regex_templates["anything"])
        self.assertEquals(re.compile('^.2*$', re.IGNORECASE), client_context.brain.regex_templates["anything"])
Ejemplo n.º 23
0
    def test_reload_aimls(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.aiml_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + 'aimls1'

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertEqual("That was test 1.", client_context.bot.ask_question(client_context, "TEST1"))
        self.assertEqual("That was test 2.", client_context.bot.ask_question(client_context, "TEST2"))

        category_engine = client.storage_factory.entity_storage_engine(StorageFactory.CATEGORIES)
        category_store = category_engine.category_store()
        category_store.get_storage()._dirs = [os.path.dirname(__file__) + os.sep + "test_config" + os.sep + 'aimls2']

        result = extension.execute(client_context, "RELOAD ALL AIML")
        self.assertEqual("HOTRELOAD OK", result)

        self.assertEqual("That was test 3.", client_context.bot.ask_question(client_context, "TEST3"))
        self.assertEqual("That was test 4.", client_context.bot.ask_question(client_context, "TEST4"))
Ejemplo n.º 24
0
    def test_reload_gender(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.gender = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "gender1.txt"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.genders)
        self.assertTrue(client_context.brain.genders.has_key(" with him "))
        self.assertFalse(client_context.brain.genders.has_key(" to him "))

        client_context.brain.configuration.files._gender = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "gender2.txt"

        result = extension.execute(client_context, "RELOAD GENDER")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.genders)
        self.assertTrue(client_context.brain.genders.has_key(" to him "))
        self.assertFalse(client_context.brain.genders.has_key(" to you "))
Ejemplo n.º 25
0
    def test_reload_set(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.set_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "sets1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.sets)
        self.assertTrue(client_context.brain.sets.contains("animal"))
        set = client_context.brain.sets.set("animal")
        self.assertTrue('BUFFALO' in set)
        del set['BUFFALO']
        self.assertFalse('BUFFALO' in set)

        result = extension.execute(client_context, "RELOAD SET ANIMAL")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.sets)
        self.assertTrue(client_context.brain.sets.contains("animal"))
        set = client_context.brain.sets.set("animal")
        self.assertTrue('BUFFALO' in set)
Ejemplo n.º 26
0
def delete_files():
    if request.method == 'POST':
        path = os.path.join(app.config['CATEGORIES_FOLDER'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(
                        os.path.join(app.config['CATEGORIES_FOLDER'], arquivo))

        path = os.path.join(app.config['BPMN_FILES'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(os.path.join(app.config['BPMN_FILES'], arquivo))

        path = os.path.join(app.config['BPMN_SIMPLIFIED'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(
                        os.path.join(app.config['BPMN_SIMPLIFIED'], arquivo))

        path = os.path.join(app.config['BPMN_FINITE_STATE'])
        caminhoAbsoluto = os.path.abspath(path)
        for pastaAtual, subPastas, arquivos in os.walk(caminhoAbsoluto):
            if pastaAtual == caminhoAbsoluto:
                for arquivo in arquivos:
                    os.remove(
                        os.path.join(app.config['BPMN_FINITE_STATE'], arquivo))

        userid = WEB_CLIENT.get_userid(request)
        client_context = WEB_CLIENT.create_client_context(userid)
        HotReloadAdminExtension.reload_all(client_context)

        return '''  
Ejemplo n.º 27
0
    def test_reload_rdfs(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.rdf_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "rdfs1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.rdf)
        self.assertTrue(client_context.brain.rdf.has_subject("ANIMAL"))
        self.assertTrue(client_context.brain.rdf.has_subject("JUPITER"))
        self.assertFalse(client_context.brain.rdf.has_subject("SOUTH"))
        self.assertFalse(client_context.brain.rdf.has_subject("IBM"))

        client_context.client.configuration.client_configuration.configurations[0].configurations[0].files._rdf_files._files = [os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "rdfs2"]

        result = extension.execute(client_context, "RELOAD ALL RDFS")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.rdf)
        self.assertFalse(client_context.brain.rdf.has_subject("ANIMAL"))
        self.assertFalse(client_context.brain.rdf.has_subject("JUPITER"))
        self.assertTrue(client_context.brain.rdf.has_subject("SOUTH"))
        self.assertTrue(client_context.brain.rdf.has_subject("IBM"))
Ejemplo n.º 28
0
    def test_reload_map(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.map_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "maps1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.maps)
        self.assertTrue(client_context.brain.maps.contains("animallegs"))
        al_map = client_context.brain.maps.map("animallegs")
        self.assertIsNotNone(al_map)
        self.assertEquals('4', al_map['BUFFALO'])
        al_map['BUFFALO'] = '6'
        self.assertEquals('6', al_map['BUFFALO'])

        result = extension.execute(client_context, "RELOAD MAP ANIMALLEGS")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.maps)
        self.assertTrue(client_context.brain.maps.contains("animallegs"))
        al_map = client_context.brain.maps.map("animallegs")
        self.assertIsNotNone(al_map)
        self.assertEquals('4', al_map['BUFFALO'])
Ejemplo n.º 29
0
    def test_reload_maps(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.map_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "maps1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.maps)
        self.assertTrue(client_context.brain.maps.contains("animallegs"))
        self.assertTrue(client_context.brain.maps.contains("animalsounds"))
        self.assertFalse(client_context.brain.maps.contains("state2captial"))
        self.assertFalse(client_context.brain.maps.contains("state2largestcity"))

        client_context.client.configuration.client_configuration.configurations[0].configurations[0].files._map_files._files = [os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "maps2"]

        result = extension.execute(client_context, "RELOAD ALL MAPS")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.maps)
        self.assertFalse(client_context.brain.maps.contains("animallegs"))
        self.assertFalse(client_context.brain.maps.contains("animalsounds"))
        self.assertTrue(client_context.brain.maps.contains("state2capital"))
        self.assertTrue(client_context.brain.maps.contains("state2largestcity"))
Ejemplo n.º 30
0
    def test_reload_sets(self):
        extension = HotReloadAdminExtension()

        ReloadTestClient.set_files = os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "sets1"

        client = ReloadTestClient()
        client_context = client.create_client_context("testid")

        self.assertIsNotNone(client_context.brain.sets)
        self.assertTrue(client_context.brain.sets.contains("animal"))
        self.assertTrue(client_context.brain.sets.contains("animals"))
        self.assertFalse(client_context.brain.sets.contains("fastfood"))
        self.assertFalse(client_context.brain.sets.contains("food"))

        client_context.client.configuration.client_configuration.configurations[0].configurations[0].files._set_files._files = [os.path.dirname(__file__) + os.sep + "test_config" + os.sep + "sets2"]

        result = extension.execute(client_context, "RELOAD ALL SETS")
        self.assertEquals("HOTRELOAD OK", result)

        self.assertIsNotNone(client_context.brain.sets)
        self.assertFalse(client_context.brain.sets.contains("animal"))
        self.assertFalse(client_context.brain.sets.contains("animals"))
        self.assertTrue(client_context.brain.sets.contains("fastfood"))
        self.assertTrue(client_context.brain.sets.contains("food"))
Ejemplo n.º 31
0
 def test_hotreload_commands(self):
     extension = HotReloadAdminExtension()
     client = ReloadTestClient()
     client_context = client.create_client_context("testid")
     self.assertEqual("RELOAD [DENORMAL|NORMAL|GENDER|PERSON|PERSON2|PROPERTIES|DEFAULTS|REGEX|PATTERNS|TEMPLATES] | [SET|MAP|RDF] NAME | ALL [AIML|MAPS|SETS|RDFS]", extension.execute(client_context, "COMMANDS"))
Ejemplo n.º 32
0
 def test_hotreload_commands(self):
     extension = HotReloadAdminExtension()
     client = ReloadTestClient()
     client_context = client.create_client_context("testid")
     self.assertEquals("RELOAD [DENORMAL|NORMAL|GENDER|PERSON|PERSON2|PROPERTIES|DEFAULTS|REGEX|PATTERNS|TEMPLATES] | [SET|MAP|RDF] NAME | ALL [AIML|MAPS|SETS|RDFS]", extension.execute(client_context, "COMMANDS"))
Ejemplo n.º 33
0
 def test_invalid_commands(self):
     extension = HotReloadAdminExtension()
     client = ReloadTestClient()
     client_context = client.create_client_context("testid")
     self.assertEqual("Unknown reload command [XXXXXX]",
                      extension.execute(client_context, "XXXXXX"))
Ejemplo n.º 34
0
 def test_reload_exception(self):
     extension = HotReloadAdminExtension()
     client = ReloadTestClient()
     client_context = client.create_client_context("testid")
     self.assertEqual("Hot Reload Admin Error",
                      extension.execute(client_context, "COMMANDS"))