def test_storage_path(self): config = FileStorageConfiguration() engine = FileStorageEngine(config) engine.initialise() store = FileCategoryStore(engine) self.assertEquals(['/tmp/categories'], store._get_storage_path()) self.assertIsInstance(store.get_storage(), FileStoreConfiguration)
def test_load_all_from_text_file_diff_extension(self): config = FileStorageConfiguration() file = os.path.dirname(__file__) + os.sep + "data" + os.sep + "categories" + os.sep + "kinghorn.aiml" self.assertTrue(os.path.exists(file)) config._categories_storage = FileStoreConfiguration(file=file, extension="xml", fileformat="xml", encoding="utf-8", delete_on_start=False) engine = FileStorageEngine(config) engine.initialise() store = FileCategoryStore(engine) parser = MockAIMLParser() store.load_all(parser) self.assertEqual(0, len(parser._parsed_files))
def test_load_all_from_test_dir_no_subdir(self): config = FileStorageConfiguration() dirs = os.path.dirname(__file__) + os.sep + "data" + os.sep + "categories" self.assertTrue(os.path.exists(dirs)) config._categories_storage = FileStoreConfiguration(dirs=[dirs], extension="aiml", subdirs=False, fileformat="xml", encoding="utf-8", delete_on_start=False) engine = FileStorageEngine(config) engine.initialise() store = FileCategoryStore(engine) parser = MockAIMLParser() store.load_all(parser) self.assertEqual(1, len(parser._parsed_files)) self.assertTrue(parser._parsed_files[0].endswith("/kinghorn.aiml"))
def category_store(self): return FileCategoryStore(self)
def test_initialise(self): config = FileStorageConfiguration() engine = FileStorageEngine(config) engine.initialise() store = FileCategoryStore(engine) self.assertEqual(store.storage_engine, engine)