Commit bf2cdca7 authored by Ivan Tyagov's avatar Ivan Tyagov

Update docs. Add test for bucket.

parent 3345371d
...@@ -35,7 +35,8 @@ from Products.ERP5Type.BTreeData import PersistentString ...@@ -35,7 +35,8 @@ from Products.ERP5Type.BTreeData import PersistentString
class DataBucketStream(Document): class DataBucketStream(Document):
""" """
Represents data stored in many small files. Represents data stored in many small files inside a "stream".
Each file is "addressed" by its key similar to dict.
""" """
meta_type = 'ERP5 Data Bucket Stream' meta_type = 'ERP5 Data Bucket Stream'
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 54, 21: Redefining built-in \'id\' (redefined-builtin)</string> <string>W: 55, 21: Redefining built-in \'id\' (redefined-builtin)</string>
<string>W: 67, 18: Redefining built-in \'id\' (redefined-builtin)</string> <string>W: 68, 18: Redefining built-in \'id\' (redefined-builtin)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -307,4 +307,37 @@ context.activate().DataStream_readChunkListAndTransform( \ ...@@ -307,4 +307,37 @@ context.activate().DataStream_readChunkListAndTransform( \
self.assertTrue( self.assertTrue(
np.array_equal(data_array.getArraySlice(0,100), \ np.array_equal(data_array.getArraySlice(0,100), \
new_array[:100])) new_array[:100]))
\ No newline at end of file def test_04_DataBucket(self):
"""
Test data bucket
"""
bucket_stream = self.portal.data_stream_module.newContent( \
portal_type = 'Data Bucket Stream')
self.tic()
self.assertEqual(0, len(bucket_stream))
# test set and get
bin_string = "1"*100000
key = len(bucket_stream) + 1
bucket_stream.insertBucket(key, bin_string )
self.assertEqual(bin_string, bucket_stream.getBucket(key))
# test sequence
self.assertEqual(1, len(bucket_stream))
# test pop
bucket_stream.popBucket(key)
self.assertEqual(0, len(bucket_stream))
# set many buckets
for i in range(100):
bucket_stream.insertBucket(i, i*10000)
self.assertEqual(100, len(bucket_stream))
self.assertEqual(range(100), bucket_stream.getKeyList())
# test as sequence
bucket = bucket_stream.getBucketItemSequence(start_key=10, count=1)[0]
self.assertEqual(100000, bucket[1].value)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment