コード例 #1
0
 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()
コード例 #2
0
 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()
コード例 #3
0
 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")
コード例 #4
0
ファイル: mysqldbds.py プロジェクト: saxix/pyslet
 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'])
コード例 #5
0
 def test_delete(self):
     bs = blockstore.FileBlockStore(dpath=self.d)
     self.cafeclosed(bs)
コード例 #6
0
 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())
コード例 #7
0
 def test_maxsize(self):
     bs = blockstore.FileBlockStore(max_block_size=256)
     self.maxsize(bs)
コード例 #8
0
 def test_store(self):
     bs = blockstore.FileBlockStore()
     self.fox_cafe(bs)
コード例 #9
0
 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")