Back to index

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

List of all members.

Public Member Functions

def test_z3interfaces
def test_getId_on_old_File_instance
def test_File_setFormat
def test_FileContentTypeUponConstruction

Private Member Functions

def _getTargetClass
def _makeOne

Detailed Description

Definition at line 36 of file test_File.py.


Member Function Documentation

Definition at line 38 of file test_File.py.

00038 
00039     def _getTargetClass(self):
00040         from Products.CMFDefault.File import File
00041 
00042         return File

def CMFDefault.tests.test_File.FileTests._makeOne (   self,
  args,
  kw 
) [private]

Definition at line 43 of file test_File.py.

00043 
00044     def _makeOne(self, *args, **kw):
00045         return self._getTargetClass()(*args, **kw)

Here is the call graph for this function:

Definition at line 64 of file test_File.py.

00064 
00065     def test_File_setFormat(self):
00066         # Setting the DC.format must also set the content_type property
00067         file = self._makeOne('testfile', format='image/jpeg')
00068         self.assertEqual(file.Format(), 'image/jpeg')
00069         self.assertEqual(file.content_type, 'image/jpeg')
00070         file.setFormat('image/gif')
00071         self.assertEqual(file.Format(), 'image/gif')
00072         self.assertEqual(file.content_type, 'image/gif')

Definition at line 73 of file test_File.py.

00073 
00074     def test_FileContentTypeUponConstruction(self):
00075         # Test the content type after calling the constructor with the
00076         # file object being passed in (http://www.zope.org/Collectors/CMF/370)
00077         testfile = open(TEST_JPG, 'rb')
00078         # Notice the cheat? File objects lack the extra intelligence that
00079         # picks content types from the actual file data, so it needs to be
00080         # helped along with a file extension...
00081         file = self._makeOne('testfile.jpg', file=testfile)
00082         testfile.close()
00083         self.assertEqual(file.Format(), 'image/jpeg')
00084         self.assertEqual(file.content_type, 'image/jpeg')
00085 

Definition at line 54 of file test_File.py.

00054 
00055     def test_getId_on_old_File_instance(self):
00056         file = self._makeOne('testfile')
00057         self.assertEqual(file.getId(), 'testfile')
00058         self.assertEqual(file.id, 'testfile')
00059         # Mimick old instance when base classes had OFS.Image.File first
00060         file.__name__ = 'testfile'
00061         delattr(file, 'id')
00062         self.assertEqual(file.getId(), 'testfile')
00063         self.assertEqual(file.id(), 'testfile')

Definition at line 46 of file test_File.py.

00046 
00047     def test_z3interfaces(self):
00048         from zope.interface.verify import verifyClass
00049         from Products.CMFDefault.interfaces import IFile
00050         from Products.CMFDefault.interfaces import IMutableFile
00051 
00052         verifyClass(IFile, self._getTargetClass())
00053         verifyClass(IMutableFile, self._getTargetClass())

Here is the call graph for this function:


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