[Zodb-checkins] SVN: ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/ Add packing tests. They fail currently.

Chris McDonough chrism at plope.com
Sun Jun 12 04:05:53 EDT 2005


Log message for revision 30758:
  Add packing tests.  They fail currently.
  

Changed:
  A   ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/packing.txt
  U   ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/test_doctests.py

-=-
Added: ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/packing.txt
===================================================================
--- ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/packing.txt	2005-06-12 05:56:37 UTC (rev 30757)
+++ ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/packing.txt	2005-06-12 08:05:53 UTC (rev 30758)
@@ -0,0 +1,93 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+Packing support for blob data
+=============================
+
+We need a database with a blob supporting storage:
+
+    >>> from ZODB.FileStorage import FileStorage
+    >>> from ZODB.Blobs.BlobStorage import BlobStorage
+    >>> from ZODB.Blobs.Blob import Blob
+    >>> from ZODB import utils
+    >>> from ZODB.DB import DB
+    >>> import transaction
+    >>> from tempfile import mkdtemp, mktemp
+    >>> storagefile = '/home/chrism/blobtest.fs'
+    >>> base_storage = FileStorage(storagefile)
+    >>> blob_dir = '/home/chrism/test_blobs'
+    >>> blob_storage = BlobStorage(blob_dir, base_storage)
+    >>> database = DB(blob_storage)
+    
+Create our root object:
+
+    >>> connection1 = database.open()
+    >>> root = connection1.root()
+
+Put some revisions of a blob object in our database and on the filesystem:
+
+    >>> import time, os
+    >>> tids = []
+    >>> times = []
+    >>> nothing = transaction.begin()
+    >>> blob = Blob()
+    >>> blob.open('w').write('this is blob data 0')
+    >>> root['blob'] = blob
+    >>> transaction.commit()
+    >>> tids.append(blob_storage._tid)
+    >>> time.sleep(1.1) # let mtime catch up (temporary)
+
+    >>> nothing = transaction.begin()
+    >>> times.append(time.time())
+    >>> root['blob'].open('w').write('this is blob data 1')
+    >>> transaction.commit()
+    >>> tids.append(blob_storage._tid)
+    >>> time.sleep(1.1) # let mtime catch up (temporary)
+
+    >>> nothing = transaction.begin()
+    >>> times.append(time.time())
+    >>> root['blob'].open('w').write('this is blob data 2')
+    >>> transaction.commit()
+    >>> tids.append(blob_storage._tid)
+    >>> time.sleep(1.1) # let mtime catch up (temporary)
+
+    >>> nothing = transaction.begin()
+    >>> times.append(time.time())
+    >>> root['blob'].open('w').write('this is blob data 3')
+    >>> transaction.commit()
+    >>> tids.append(blob_storage._tid)
+    >>> time.sleep(1.1) # let mtime catch up (temporary)
+
+    >>> nothing = transaction.begin()
+    >>> times.append(time.time())
+    >>> root['blob'].open('w').write('this is blob data 4')
+    >>> transaction.commit()
+    >>> tids.append(blob_storage._tid)
+    >>> time.sleep(1.1) # let mtime catch up (temporary)
+
+    >>> oid = root['blob']._p_oid
+    >>> fns = [ blob_storage._getCleanFilename(oid, x) for x in tids ]
+    >>> fns
+    >>> [ os.path.exists(x) for x in fns ]
+    [True, True, True, True, True]
+
+Do a pack to the slightly before the last revision was written:
+
+    >>> from ZODB.serialize import referencesf
+    >>> packtime = times[-1]
+    >>> blob_storage.pack(packtime, referencesf)
+    >>> fns = [ blob_storage._getCleanFilename(oid, x) for x in tids ]
+    >>> [ os.path.exists(x) for x in fns ]
+    [True, True, True, True, False]
+    

Modified: ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/test_doctests.py
===================================================================
--- ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/test_doctests.py	2005-06-12 05:56:37 UTC (rev 30757)
+++ ZODB/branches/ctheune-blobsupport/src/ZODB/Blobs/tests/test_doctests.py	2005-06-12 08:05:53 UTC (rev 30758)
@@ -15,4 +15,5 @@
 from zope.testing.doctestunit import DocFileSuite
 
 def test_suite():
-    return DocFileSuite("../Blob.txt",  "connection.txt", "transaction.txt")
+    return DocFileSuite("../Blob.txt",  "connection.txt", "transaction.txt",
+                        "packing.txt")



More information about the Zodb-checkins mailing list