def hashStore(request, tmpdir_factory): if request.param == HS_MEMORY: yield MemoryHashStore() else: hs = DbHashStore(tmpdir_factory.mktemp('').strpath, db_type=request.param) hs.reset() yield hs hs.close()
def initHashStore(data_dir, name, config=None) -> HashStore: """ Create and return a hashStore implementation based on configuration """ config = config or getConfig() hsConfig = config.hashStore['type'].lower() if hsConfig == HS_FILE: return FileHashStore(dataDir=data_dir, fileNamePrefix=name) elif hsConfig == HS_LEVELDB or hsConfig == HS_ROCKSDB: return DbHashStore(dataDir=data_dir, fileNamePrefix=name, db_type=hsConfig) else: return MemoryHashStore()
def testInvalidDBType(tmpdir_factory): HS_WRONGDB = 'somedb' assert HS_WRONGDB not in (HS_LEVELDB, HS_ROCKSDB) with pytest.raises(ValueError) as excinfo: DbHashStore('', db_type=HS_WRONGDB) assert "one of {}".format((HS_ROCKSDB, HS_LEVELDB)) in str(excinfo.value)
def hashStore(request, tmpdir_factory): hs = DbHashStore(tmpdir_factory.mktemp('').strpath, db_type=request.param) cleanup(hs) yield hs hs.close()
def get_auction_hash_store(data_dir): return DbHashStore(dataDir=data_dir, fileNamePrefix='auction', db_type=HS_LEVELDB)
def get_graphchain_hash_store(data_dir): logger.info("Creating LEI hash store in '{}'.".format(data_dir)) return DbHashStore(dataDir=data_dir, fileNamePrefix=GRAPHCHAIN_HASH_STORE_NAME, db_type=HS_ROCKSDB)