def test_load_from_test_dir_with_subdir(self): config = FileStorageConfiguration() config._maps_storage = FileStoreConfiguration(dirs=[ os.path.dirname(__file__) + os.sep + "data" + os.sep + "maps" + os.sep + "text" ], extension="txt", subdirs=True, format="text", encoding="utf-8", delete_on_start=False) engine = FileStorageEngine(config) engine.initialise() store = FileMapsStore(engine) map_collection = MapCollection() store.load_all(map_collection) self.assertTrue(map_collection.contains('TESTMAP')) the_map = map_collection.map('TESTMAP') self.assertIsNotNone(the_map) self.assertEqual("6", the_map['ANT']) self.assertTrue(map_collection.contains('TESTMAP2')) the_map = map_collection.map('TESTMAP2') self.assertIsNotNone(the_map) self.assertEqual("grrrrr", the_map['BEAR'])
def test_reload_no_engine(self): storage_factory = StorageFactory() file_store_config = FileStorageConfiguration() file_store_config._maps_storage = FileStoreConfiguration(dirs=[ os.path.dirname(__file__) + os.sep + "test_files" + os.sep + "maps" ]) collection = MapCollection() self.assertIsNotNone(collection) self.assertTrue(collection.reload(storage_factory, "TEST_MAP") == 0)
def test_load_with_exception(self): storage_factory = StorageFactory() file_store_config = FileStorageConfiguration() file_store_config._maps_storage = FileStoreConfiguration(dirs=[ os.path.dirname(__file__) + os.sep + "test_files" + os.sep + "maps" ]) storage_engine = FileStorageEngine(file_store_config) storage_factory._storage_engines[StorageFactory.MAPS] = storage_engine storage_factory._store_to_engine_map[ StorageFactory.MAPS] = storage_engine collection = MapCollection() self.assertIsNotNone(collection) self.assertTrue(collection.load(storage_factory) == 0)
def test_reload_from_file(self): storage_factory = StorageFactory() file_store_config = FileStorageConfiguration() file_store_config._maps_storage = FileStoreConfiguration(dirs=[ os.path.dirname(__file__) + os.sep + "test_files" + os.sep + "maps" ]) storage_engine = FileStorageEngine(file_store_config) storage_factory._storage_engines[StorageFactory.MAPS] = storage_engine storage_factory._store_to_engine_map[ StorageFactory.MAPS] = storage_engine collection = MapCollection() self.assertIsNotNone(collection) collection.load(storage_factory) self.assertTrue(collection.contains("TEST_MAP")) collection.reload(storage_factory, "TEST_MAP") self.assertTrue(collection.contains("TEST_MAP"))