Esempio n. 1
0
    def test_storage_path(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileErrorsStore(engine)

        self.assertEquals('/tmp/debug/errors.txt', store._get_storage_path())
        self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
Esempio n. 2
0
    def test_load_errors_no_file(self):
        config = FileStorageConfiguration()
        tmpdir = os.path.dirname(__file__) + os.sep + "errors"
        tmpfile = tmpdir + os.sep + "errors.txt"
        config.errors_storage._dirs = [tmpfile]
        config.errors_storage._has_single_file = True
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileErrorsStore(engine)

        path = store._get_dir_from_path(store._get_storage_path())
        if os.path.exists(path):
            shutil.rmtree(path)
        self.assertFalse(os.path.exists(path))

        errorInfo = store.load_errors()
        self.assertIsNone(errorInfo)
Esempio n. 3
0
    def test_empty(self):
        config = FileStorageConfiguration()
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileErrorsStore(engine)

        if os.path.exists(store._get_storage_path()) is False:
            os.mkdir(store._get_storage_path())

        store.empty()

        self.assertFalse(os.path.exists(store._get_storage_path()))
Esempio n. 4
0
    def test_save_errors_with_exception(self):
        config = FileStorageConfiguration()
        tmpdir = os.path.dirname(__file__) + os.sep + "errors"
        tmpfile = tmpdir + os.sep + "errors.txt"
        config.errors_storage._dirs = [tmpfile]
        config.errors_storage._has_single_file = True
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileErrorsStore(engine)

        path = store._get_dir_from_path(store._get_storage_path())
        if os.path.exists(path):
            shutil.rmtree(path)
        self.assertFalse(os.path.exists(path))

        errors = [["Error1", "aiml1.xml", "100", "200"]]
        store.save_errors(errors)

        self.assertFalse(os.path.exists(store._get_storage_path()))
Esempio n. 5
0
 def errors_store(self):
     return FileErrorsStore(self)
Esempio n. 6
0
    def test_load_errors(self):
        config = FileStorageConfiguration()
        tmpdir = os.path.dirname(__file__) + os.sep + "errors"
        tmpfile = tmpdir + os.sep + "errors.txt"
        config.errors_storage._dirs = [tmpfile]
        config.errors_storage._has_single_file = True
        engine = FileStorageEngine(config)
        engine.initialise()
        store = FileErrorsStore(engine)

        path = store._get_dir_from_path(store._get_storage_path())
        if os.path.exists(path):
            shutil.rmtree(path)
        self.assertFalse(os.path.exists(path))

        store.empty()

        errors = [["aiml1.xml", "10", "20", "1", "5", "node", "Error_1"]]
        store.save_errors(errors)
        self.assertTrue(os.path.exists(store._get_storage_path()))

        errorInfo = store.load_errors()
        self.assertIsNotNone(errorInfo)
        self.assertIsNotNone(errorInfo['errors'])
        errors = errorInfo['errors']
        error = errors[0]
        self.assertEqual("aiml1.xml", error['file'])

        store.empty()
        self.assertFalse(os.path.exists(store._get_storage_path()))

        shutil.rmtree(tmpdir)
        self.assertFalse(os.path.exists(tmpdir))
Esempio n. 7
0
 def test_initialise(self):
     config = FileStorageConfiguration()
     engine = FileStorageEngine(config)
     engine.initialise()
     store = FileErrorsStore(engine)
     self.assertEqual(store.storage_engine, engine)