def test_mem_file(self): self.container = InMemoryEntityContainer(self.cdef) self.bs = blockstore.FileBlockStore(dpath=self.d, max_block_size=self.block_size) self.ls = blockstore.LockStore(entity_set=self.cdef['BlockLocks']) self.ss = blockstore.StreamStore(bs=self.bs, ls=self.ls, entity_set=self.cdef['Streams']) self.random_rw()
def test_sql_file(self): self.container = BlockStoreContainer(container=self.cdef, file_path=str( self.d.join('blockstore.db'))) self.container.create_all_tables() self.bs = blockstore.FileBlockStore(dpath=self.d, max_block_size=self.block_size) self.ls = blockstore.LockStore(entity_set=self.cdef['BlockLocks']) self.ss = blockstore.StreamStore(bs=self.bs, ls=self.ls, entity_set=self.cdef['Streams']) self.random_rw()
def test_dpath(self): bs = blockstore.FileBlockStore(dpath=self.d) fox = b"The quick brown fox jumped over the lazy dog" kfox = bs.store(fox) # default algorithm is to split twice d1 = self.d.join(kfox[0:2]) self.assertTrue(d1.isdir(), "d1 exists") d2 = d1.join(kfox[2:4]) self.assertTrue(d2.isdir(), "d2 exists") d3 = d2.join(kfox[4:6]) self.assertFalse(d3.isdir(), "d3 does not exist") block = d2.join(kfox[4:]) self.assertTrue(block.isfile(), "file exists")
def __init__(self, db, dpath=None, **kwargs): self.container_def = self.load_container() #: the :py:class:`MySQLEntityContainer` used for the blockstore self.container = MySQLEntityContainer(db=db, container=self.container_def, **kwargs) if dpath is None: bs = blockstore.FileBlockStore(dpath) else: bs = blockstore.EDMBlockStore( entity_set=self.container_def['Blocks']) ls = blockstore.LockStore(entity_set=self.container_def['Locks']) blockstore.StreamStore.__init__(self, bs, ls, self.container_def['Streams'])
def test_delete(self): bs = blockstore.FileBlockStore(dpath=self.d) self.cafeclosed(bs)
def test_hash(self): bs = blockstore.FileBlockStore(hash_class=hashlib.md5) fox = b"The quick brown fox jumped over the lazy dog" kfox = bs.store(fox) self.assertTrue(len(kfox) == 32) self.assertTrue(kfox == hashlib.md5(fox).hexdigest().lower())
def test_maxsize(self): bs = blockstore.FileBlockStore(max_block_size=256) self.maxsize(bs)
def test_store(self): bs = blockstore.FileBlockStore() self.fox_cafe(bs)
def test_init(self): bs = blockstore.FileBlockStore() self.assertTrue(bs.max_block_size == blockstore.MAX_BLOCK_SIZE, "default block size") self.assertTrue(bs.hash_class is hashlib.sha256, "default hash_class SHA256")