Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
CMFDefault.tests.test_Image.TestImageElement Class Reference
Inheritance diagram for CMFDefault.tests.test_Image.TestImageElement:
Inheritance graph
[legend]
Collaboration diagram for CMFDefault.tests.test_Image.TestImageElement:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def test_z3interfaces
def test_getId_on_old_Image_instance
def test_EditWithEmptyFile
def test_Image_setFormat
def test_ImageContentTypeUponConstruction

Public Attributes

 site

Private Member Functions

def _getTargetClass
def _makeOne

Detailed Description

Definition at line 43 of file test_Image.py.


Member Function Documentation

Definition at line 45 of file test_Image.py.

00045 
00046     def _getTargetClass(self):
00047         from Products.CMFDefault.Image import Image
00048 
00049         return Image

def CMFDefault.tests.test_Image.TestImageElement._makeOne (   self,
  args,
  kw 
) [private]

Definition at line 50 of file test_Image.py.

00050 
00051     def _makeOne(self, *args, **kw):
00052         return self._getTargetClass()(*args, **kw)

Here is the call graph for this function:

Definition at line 53 of file test_Image.py.

00053 
00054     def setUp(self):
00055         self.site = DummySite('site')
00056         self.site._setObject( 'portal_membership', DummyTool() )

Definition at line 79 of file test_Image.py.

00079 
00080     def test_EditWithEmptyFile(self):
00081         # Test handling of empty file uploads
00082         image = self.site._setObject('testimage', self._makeOne('testimage'))
00083 
00084         testfile = open(TEST_JPG, 'rb')
00085         image.edit(file=testfile)
00086         testfile.seek(0,2)
00087         testfilesize = testfile.tell()
00088         testfile.close()
00089 
00090         assert image.get_size() == testfilesize
00091 
00092         emptyfile = StringIO()
00093         image.edit(file=emptyfile)
00094 
00095         assert image.get_size() > 0
00096         assert image.get_size() == testfilesize

Definition at line 69 of file test_Image.py.

00069 
00070     def test_getId_on_old_Image_instance(self):
00071         image = self.site._setObject('testimage', self._makeOne('testimage'))
00072         self.assertEqual(image.getId(), 'testimage')
00073         self.assertEqual(image.id, 'testimage')
00074         # Mimick old instance when base classes had OFS.Image.Image first
00075         image.__name__ = 'testimage'
00076         delattr(image, 'id')
00077         self.assertEqual(image.getId(), 'testimage')
00078         self.assertEqual(image.id(), 'testimage')

Definition at line 97 of file test_Image.py.

00097 
00098     def test_Image_setFormat(self):
00099         # Setting the DC.format must also set the content_type property
00100         image = self._makeOne('testimage', format='image/jpeg')
00101         self.assertEqual(image.Format(), 'image/jpeg')
00102         self.assertEqual(image.content_type, 'image/jpeg')
00103         image.setFormat('image/gif')
00104         self.assertEqual(image.Format(), 'image/gif')
00105         self.assertEqual(image.content_type, 'image/gif')

Definition at line 106 of file test_Image.py.

00106 
00107     def test_ImageContentTypeUponConstruction(self):
00108         # Test the content type after calling the constructor with the
00109         # file object being passed in (http://www.zope.org/Collectors/CMF/370)
00110         testfile = open(TEST_JPG, 'rb')
00111         image = self._makeOne('testimage', file=testfile)
00112         testfile.close()
00113         self.assertEqual(image.Format(), 'image/jpeg')
00114         self.assertEqual(image.content_type, 'image/jpeg')
00115 

Definition at line 57 of file test_Image.py.

00057 
00058     def test_z3interfaces(self):
00059         from zope.interface.verify import verifyClass
00060         from Products.CMFDefault.interfaces import IFile
00061         from Products.CMFDefault.interfaces import IImage
00062         from Products.CMFDefault.interfaces import IMutableFile
00063         from Products.CMFDefault.interfaces import IMutableImage
00064 
00065         verifyClass(IFile, self._getTargetClass())
00066         verifyClass(IImage, self._getTargetClass())
00067         verifyClass(IMutableFile, self._getTargetClass())
00068         verifyClass(IMutableImage, self._getTargetClass())

Here is the call graph for this function:


Member Data Documentation

Definition at line 54 of file test_Image.py.


The documentation for this class was generated from the following file: