Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Attributes
Archetypes.tests.test_metadata.ExtMetadataSetFormatTest Class Reference
Inheritance diagram for Archetypes.tests.test_metadata.ExtMetadataSetFormatTest:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.tests.test_metadata.ExtMetadataSetFormatTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testSetFormat
def testSetContentType
def testMultipleChanges
def testChangesOnFieldChangesObject
def testDiscussionEditAccessorDoesConversions
def testDiscussionOverride

Static Public Attributes

string value = "fooooo"
string filename = 'foo.txt'

Private Attributes

 _parent
 _dummy

Detailed Description

Definition at line 230 of file test_metadata.py.


Member Function Documentation

Definition at line 235 of file test_metadata.py.

00235 
00236     def afterSetUp(self):
00237         portal = self.portal
00238 
00239         # to enable overrideDiscussionFor
00240         self.setRoles(['Manager'])
00241 
00242         parent = mkDummyInContext(DummyFolder, oid='parent', context=portal, schema=None)
00243         self._parent = parent
00244 
00245         # create dummy in context of a plone folder
00246         dummy = mkDummyInContext(Dummy, oid='dummy', context=parent, schema=None)
00247         self._dummy = dummy
00248 
00249         pfield = dummy.getPrimaryField()
00250         # tests do need afilefield
00251         self.failUnlessEqual(pfield.getName(), 'afilefield')
00252         pfield.set(dummy, self.value, filename=self.filename, mimetype='text/plain')
00253 
00254         self._parent.dummy = dummy

Here is the call graph for this function:

Definition at line 309 of file test_metadata.py.

00309 
00310     def testChangesOnFieldChangesObject(self):
00311         dummy = self._parent.dummy
00312         pfield = dummy.getPrimaryField()
00313 
00314         data = pfield.get(dummy)
00315         self.failUnlessEqual(data.content_type, 'text/plain')
00316 
00317         data.content_type = 'image/jpeg'
00318 
00319         self.failUnlessEqual(data.content_type, 'image/jpeg')
00320 
00321         pfield.set(dummy, data)
00322         self.failUnlessEqual(dummy.Format(), 'image/jpeg')
00323         self.failUnlessEqual(dummy.getContentType(), 'image/jpeg')
00324         self.failUnlessEqual(dummy.content_type, 'image/jpeg')
00325         self.failUnlessEqual(dummy.get_content_type(), 'image/jpeg')
00326         self.failUnlessEqual(pfield.getContentType(dummy), 'image/jpeg')

Definition at line 327 of file test_metadata.py.

00327 
00328     def testDiscussionEditAccessorDoesConversions(self):
00329         # Use a DDocument because the dummy is too dumb for this
00330         self.folder.invokeFactory('DDocument','bogus_item')
00331         dummy = self.folder.bogus_item
00332         # Set Allow discussion
00333         dummy.allowDiscussion(True)
00334         self.failUnless(dummy.isDiscussable())
00335         self.assertEqual(dummy.editIsDiscussable(), True)
00336         dummy.allowDiscussion(None)
00337         self.assertEqual(dummy.editIsDiscussable(), False)
00338         self.assertEqual(dummy.rawIsDiscussable(), None)
00339         dummy.allowDiscussion(False)
00340         self.failIf(dummy.isDiscussable())
00341         self.assertEqual(dummy.editIsDiscussable(), False)
        

Definition at line 342 of file test_metadata.py.

00342 
00343     def testDiscussionOverride(self):
00344         # Make sure that if allowed_discussion is set on the class
00345         # we can still use allowDiscussion to override it.
00346         #
00347         # Use a DDocument because the dummy is too dumb for this
00348         # but temporarily set an allow_discussion attribute on the class.
00349         from Products.Archetypes.examples.DDocument import DDocument
00350         DDocument.allow_discussion = True
00351         self.folder.invokeFactory('DDocument','bogus_item')
00352         dummy = self.folder.bogus_item
00353         dummy.allowDiscussion(None)
00354         # clear our bogus attribute
00355         del DDocument.allow_discussion
00356 

Definition at line 295 of file test_metadata.py.

00295 
00296     def testMultipleChanges(self):
00297         dummy = self._parent.dummy
00298         pfield = dummy.getPrimaryField()
00299 
00300         dummy.setContentType('image/gif')
00301         self.failUnlessEqual(dummy.getContentType(), 'image/gif')
00302         dummy.setFormat('application/pdf')
00303         self.failUnlessEqual(dummy.Format(), 'application/pdf')
00304         dummy.setContentType('image/jpeg')
00305         self.failUnlessEqual(dummy.Format(), 'image/jpeg')
00306 
00307         self.failUnlessEqual(pfield.get(dummy).filename, self.filename)
00308         self.failUnlessEqual(pfield.get(dummy).data, self.value)

Definition at line 274 of file test_metadata.py.

00274 
00275     def testSetContentType(self):
00276         dummy = self._parent.dummy
00277         pfield = dummy.getPrimaryField()
00278 
00279         dummy.setContentType('text/plain')
00280         self.failUnlessEqual(dummy.Format(), 'text/plain')
00281         self.failUnlessEqual(dummy.getContentType(), 'text/plain')
00282         self.failUnlessEqual(dummy.content_type, 'text/plain')
00283         self.failUnlessEqual(dummy.get_content_type(), 'text/plain')
00284         self.failUnlessEqual(pfield.getContentType(dummy), 'text/plain')
00285         self.failUnlessEqual(pfield.get(dummy).content_type, 'text/plain')
00286 
00287         dummy.setContentType('image/gif')
00288         self.failUnlessEqual(dummy.Format(), 'image/gif')
00289         self.failUnlessEqual(dummy.getContentType(), 'image/gif')
00290         self.failUnlessEqual(dummy.content_type, 'image/gif')
00291         self.failUnlessEqual(dummy.get_content_type(), 'image/gif')
00292         self.failUnlessEqual(pfield.getContentType(dummy), 'image/gif')
00293         self.failUnlessEqual(pfield.get(dummy).content_type, 'image/gif')
00294 

Definition at line 255 of file test_metadata.py.

00255 
00256     def testSetFormat(self):
00257         dummy = self._parent.dummy
00258         pfield = dummy.getPrimaryField()
00259 
00260         self.failUnlessEqual(dummy.Format(), 'text/plain')
00261         self.failUnlessEqual(dummy.getContentType(), 'text/plain')
00262         self.failUnlessEqual(dummy.content_type, 'text/plain')
00263         self.failUnlessEqual(dummy.get_content_type(), 'text/plain')
00264         self.failUnlessEqual(pfield.getContentType(dummy), 'text/plain')
00265         self.failUnlessEqual(pfield.get(dummy).content_type, 'text/plain')
00266 
00267         dummy.setFormat('image/gif')
00268         self.failUnlessEqual(dummy.Format(), 'image/gif')
00269         self.failUnlessEqual(dummy.getContentType(), 'image/gif')
00270         self.failUnlessEqual(dummy.content_type, 'image/gif')
00271         self.failUnlessEqual(dummy.get_content_type(), 'image/gif')
00272         self.failUnlessEqual(pfield.getContentType(dummy), 'image/gif')
00273         self.failUnlessEqual(pfield.get(dummy).content_type, 'image/gif')


Member Data Documentation

Definition at line 246 of file test_metadata.py.

Definition at line 242 of file test_metadata.py.

Definition at line 233 of file test_metadata.py.

Definition at line 232 of file test_metadata.py.


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