Пример #1
0
    def test_storage_path(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileRegexStore(engine)

        self.assertEquals('/tmp/regex/regex-templates.txt', store._get_storage_path())
        self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
Пример #2
0
    def test_load_regex(self):
        config = FileStorageConfiguration()
        config._regex_storage =  FileStoreConfiguration(file=os.path.dirname(__file__) + os.sep + "data" + os.sep + "lookups" + os.sep + "text" + os.sep + "regex-templates.txt", fileformat="text", encoding="utf-8", delete_on_start=False)
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileRegexStore(engine)

        collection = RegexTemplatesCollection()
        store.load(collection)

        self.assertIsNotNone(store.get_regular_expressions())
        self.assertTrue(collection.has_regex("anything"))
        self.assertEqual(re.compile('^.*$', re.IGNORECASE), collection.regex("anything"))
        self.assertTrue(collection.has_regex("legion"))
        self.assertFalse(collection.has_regex("XXXXX"))
Пример #3
0
 def regex_store(self):
     return FileRegexStore(self)
Пример #4
0
 def test_initialise(self):
     config = FileStorageConfiguration()
     engine = FileStorageEngine(config)
     engine.initialise()
     store = FileRegexStore(engine)
     self.assertEqual(store.storage_engine, engine)