[Checkins] SVN: z3c.blobfile/trunk/src/z3c/blobfile/ Moved compatibility test with zope.app.File into the readme file.

Uwe Oestermeier u.oestermeier at iwm-kmrc.de
Mon Nov 12 08:55:11 EST 2007


Log message for revision 81767:
  Moved compatibility test with zope.app.File into the readme file.

Changed:
  U   z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt
  U   z3c.blobfile/trunk/src/z3c/blobfile/file.py

-=-
Modified: z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt
===================================================================
--- z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt	2007-11-12 13:50:56 UTC (rev 81766)
+++ z3c.blobfile/trunk/src/z3c/blobfile/blobfile.txt	2007-11-12 13:55:10 UTC (rev 81767)
@@ -2,7 +2,104 @@
 ========================
 
 
+
+
+Compatibility with zope.app.file.File
+-------------------------------------
+
+This test mimics exactly the tests of the zope.app.file package:
+
+    Let's test the constructor:
+
     >>> file = File()
+    >>> file.contentType
+    ''
+    >>> file.data
+    ''
+
+    >>> file = File('Foobar')
+    >>> file.contentType
+    ''
+    >>> file.data
+    'Foobar'
+
+    >>> file = File('Foobar', 'text/plain')
+    >>> file.contentType
+    'text/plain'
+    >>> file.data
+    'Foobar'
+
+    >>> file = File(data='Foobar', contentType='text/plain')
+    >>> file.contentType
+    'text/plain'
+    >>> file.data
+    'Foobar'
+
+
+    Let's test the mutators:
+
+    >>> file = File()
+    >>> file.contentType = 'text/plain'
+    >>> file.contentType
+    'text/plain'
+
+    >>> file.data = 'Foobar'
+    >>> file.data
+    'Foobar'
+
+    >>> file.data = None
+    Traceback (most recent call last):
+    ...
+    TypeError: Cannot set None data on a file.
+
+
+    Let's test large data input:
+
+    >>> file = File()
+
+    Insert as string:
+
+    >>> file.data = 'Foobar'*60000
+    >>> file.getSize()
+    360000
+    >>> file.data == 'Foobar'*60000
+    True
+
+    Insert data as FileChunk:
+
+    >>> fc = FileChunk('Foobar'*4000)
+    >>> file.data = fc
+    >>> file.getSize()
+    24000
+    >>> file.data == 'Foobar'*4000
+    True
+
+    Insert data from file object:
+
+    >>> import cStringIO
+    >>> sio = cStringIO.StringIO()
+    >>> sio.write('Foobar'*100000)
+    >>> sio.seek(0)
+    >>> file.data = sio
+    >>> file.getSize()
+    600000
+    >>> file.data == 'Foobar'*100000
+    True
+
+
+    Last, but not least, verify the interface:
+
+    >>> from zope.interface.verify import verifyClass
+    >>> zope.app.file.interfaces.IFile.implementedBy(File)
+    True
+    >>> verifyClass(zope.app.file.interfaces.IFile, File)
+    True
+
+
+Test of Filerepresentation Adapters
+-----------------------------------
+
+    >>> file = File()
     >>> content = "This is some file\\ncontent."
     >>> file.data = content
     >>> file.contentType = "text/plain"

Modified: z3c.blobfile/trunk/src/z3c/blobfile/file.py
===================================================================
--- z3c.blobfile/trunk/src/z3c/blobfile/file.py	2007-11-12 13:50:56 UTC (rev 81766)
+++ z3c.blobfile/trunk/src/z3c/blobfile/file.py	2007-11-12 13:55:10 UTC (rev 81767)
@@ -34,111 +34,8 @@
 MAXCHUNKSIZE = 1 << 16
 
 class File(Persistent):
-    """A persistent content component storing binary file data
+    """A persistent content component storing binary file data."""
 
-    XXX: Don't know how to set up utilities for tests correctly::
-
-      >>> import storages
-      >>> zope.component.provideUtility(storages.StringStorable,
-      ...                               interfaces.IStorage,
-      ...                               name="__builtin__.str")
-      >>> zope.component.provideUtility(storages.UnicodeStorable,
-      ...                               interfaces.IStorage,
-      ...                               name="__builtin__.unicode")
-      >>> zope.component.provideUtility(storages.FileChunkStorable,
-      ...                               interfaces.IStorage,
-      ...                               name="zope.app.file.file.FileChunk")
-      >>> zope.component.provideUtility(storages.FileDescriptorStorable,
-      ...                               interfaces.IStorage,
-      ...                               name="__builtin__.file")
-
-    Let's test the constructor:
-
-    >>> file = File()
-    >>> file.contentType
-    ''
-    >>> file.data
-    ''
-
-    >>> file = File('Foobar')
-    >>> file.contentType
-    ''
-    >>> file.data
-    'Foobar'
-
-    >>> file = File('Foobar', 'text/plain')
-    >>> file.contentType
-    'text/plain'
-    >>> file.data
-    'Foobar'
-
-    >>> file = File(data='Foobar', contentType='text/plain')
-    >>> file.contentType
-    'text/plain'
-    >>> file.data
-    'Foobar'
-
-
-    Let's test the mutators:
-
-    >>> file = File()
-    >>> file.contentType = 'text/plain'
-    >>> file.contentType
-    'text/plain'
-
-    >>> file.data = 'Foobar'
-    >>> file.data
-    'Foobar'
-
-    >>> file.data = None
-    Traceback (most recent call last):
-    ...
-    TypeError: Cannot set None data on a file.
-
-
-    Let's test large data input:
-
-    >>> file = File()
-
-    Insert as string:
-
-    >>> file.data = 'Foobar'*60000
-    >>> file.getSize()
-    360000
-    >>> file.data == 'Foobar'*60000
-    True
-
-    Insert data as FileChunk:
-
-    >>> fc = FileChunk('Foobar'*4000)
-    >>> file.data = fc
-    >>> file.getSize()
-    24000
-    >>> file.data == 'Foobar'*4000
-    True
-
-    Insert data from file object:
-
-    >>> import cStringIO
-    >>> sio = cStringIO.StringIO()
-    >>> sio.write('Foobar'*100000)
-    >>> sio.seek(0)
-    >>> file.data = sio
-    >>> file.getSize()
-    600000
-    >>> file.data == 'Foobar'*100000
-    True
-
-
-    Last, but not least, verify the interface:
-
-    >>> from zope.interface.verify import verifyClass
-    >>> zope.app.file.interfaces.IFile.implementedBy(File)
-    True
-    >>> verifyClass(zope.app.file.interfaces.IFile, File)
-    True
-    """
-
     implements(zope.app.publication.interfaces.IFileContent, 
                zope.app.file.interfaces.IFile)
 



More information about the Checkins mailing list