[Zope-CVS] CVS: Products/AdaptableStorage/tests - Zope2TestBase.py:1.5

Shane Hathaway shane@zope.com
Tue, 14 Jan 2003 12:46:34 -0500


Update of /cvs-repository/Products/AdaptableStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv7693/tests

Modified Files:
	Zope2TestBase.py 
Log Message:
Added a test of uploading large OFS.File objects.


=== Products/AdaptableStorage/tests/Zope2TestBase.py 1.4 => 1.5 ===
--- Products/AdaptableStorage/tests/Zope2TestBase.py:1.4	Fri Jan 10 13:31:13 2003
+++ Products/AdaptableStorage/tests/Zope2TestBase.py	Tue Jan 14 12:46:31 2003
@@ -16,12 +16,15 @@
 $Id$
 """
 
+from cStringIO import StringIO
+
 from Acquisition import aq_base
 from ZODB import Persistent, POSException
 from Persistence import PersistentMapping
 from OFS.Folder import Folder
 from OFS.ObjectManager import ObjectManager
 from OFS.SimpleItem import SimpleItem
+from OFS.Image import manage_addFile
 from AccessControl.User import User, UserFolder
 
 from Products.AdaptableStorage.patches import applySetObPatch
@@ -300,3 +303,25 @@
 
         finally:
             conn.close()
+
+
+    def testLargeFile(self):
+        # Verify that 256K file objects can be serialized/deserialized.
+        # Zope splits files larger than 64K into chunks.
+        data = 'data' * 65536
+        conn = self.db.open()
+        try:
+            app = conn.root()['Application']
+            manage_addFile(app, 'file', StringIO(data))
+            get_transaction().commit()
+
+            self.assertEqual(str(app.file), data)
+            conn2 = self.db.open()
+            try:
+                app = conn2.root()['Application']
+                self.assertEqual(str(app.file), data)
+            finally:
+                conn2.close()
+        finally:
+            conn.close()
+