Back to index

plone3  3.1.7
Public Member Functions | Private Attributes
ATContentTypes.tests.test_atdocument.TestATDocumentFields Class Reference
Inheritance diagram for ATContentTypes.tests.test_atdocument.TestATDocumentFields:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tests.test_atdocument.TestATDocumentFields:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def test_text_field_mutator_filename
def test_text_field_mutator_mime
def test_text_field_mutator_none_mime
def test_text_field_mutator_none_filename
def test_text_setEmptyText
def test_textField
def createDummy
def test_description
def test_id
def test_relateditems

Private Attributes

 _dummy

Detailed Description

Definition at line 195 of file test_atdocument.py.


Member Function Documentation

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTFieldTestCase.

Definition at line 197 of file test_atdocument.py.

00197 
00198     def afterSetUp(self):
00199         atcttestcase.ATCTFieldTestCase.afterSetUp(self)
00200         self._dummy = self.createDummy(klass=ATDocument)

def ATContentTypes.tests.atcttestcase.ATCTFieldTestCase.createDummy (   self,
  klass,
  id = 'dummy' 
) [inherited]

Definition at line 243 of file atcttestcase.py.

00243 
00244     def createDummy(self, klass, id='dummy'):
00245         portal = self.portal
00246         dummy = klass(oid=id)
00247         # put dummy in context of portal
00248         dummy = dummy.__of__(portal)
00249         portal.dummy = dummy
00250         dummy.initializeArchetype()
00251         return dummy

Here is the call graph for this function:

Definition at line 252 of file atcttestcase.py.

00252 
00253     def test_description(self):
00254         dummy = self._dummy
00255         field = dummy.getField('description')
00256 
00257         self.failUnless(ILayerContainer.isImplementedBy(field))
00258         self.failUnlessEqual(field.required, False)
00259         self.failUnlessEqual(field.default, '')
00260         self.failUnlessEqual(field.searchable, True)
00261         self.failUnlessEqual(field.primary, False)
00262         vocab = field.vocabulary
00263         self.failUnlessEqual(vocab, ())
00264         self.failUnlessEqual(field.enforceVocabulary, False)
00265         self.failUnlessEqual(field.multiValued, False)
00266         self.failUnlessEqual(field.isMetadata, True)
00267         self.failUnlessEqual(field.accessor, 'Description')
00268         self.failUnlessEqual(field.mutator, 'setDescription')
00269         self.failUnlessEqual(field.edit_accessor, 'getRawDescription')
00270         self.failUnlessEqual(field.read_permission, View)
00271         self.failUnlessEqual(field.write_permission, ModifyPortalContent)
00272         self.failUnlessEqual(field.generateMode, 'mVc')
00273         #self.failUnless(field.generateMode == 'veVc', field.generateMode)
00274         self.failUnlessEqual(field.force, '')
00275         self.failUnlessEqual(field.type, 'text')
00276         self.failUnless(isinstance(field.storage, MetadataStorage))
00277         self.failUnless(field.getLayerImpl('storage') == MetadataStorage())
00278         self.failUnlessEqual(field.validators, EmptyValidator)
00279         self.failUnless(isinstance(field.widget, TextAreaWidget))
00280         vocab = field.Vocabulary(dummy)
00281         self.failUnless(isinstance(vocab, DisplayList))
00282         self.failUnlessEqual(tuple(vocab), ())

Definition at line 283 of file atcttestcase.py.

00283 
00284     def test_id(self):
00285         dummy = self._dummy
00286         field = dummy.getField('id')
00287 
00288         self.failUnless(ILayerContainer.isImplementedBy(field))
00289         self.failUnlessEqual(field.required, False)
00290         self.failUnlessEqual(field.default, None)
00291         self.failUnlessEqual(field.searchable, True)
00292         self.failUnlessEqual(getattr(field, 'primary', None), None)
00293         vocab = field.vocabulary
00294         self.failUnlessEqual(vocab, ())
00295         self.failUnlessEqual(field.enforceVocabulary, False)
00296         self.failUnlessEqual(field.multiValued, False)
00297         self.failUnlessEqual(field.isMetadata, False)
00298         self.failUnlessEqual(field.accessor, 'getId')
00299         self.failUnlessEqual(field.mutator, 'setId')
00300         self.failUnlessEqual(field.edit_accessor, 'getRawId')
00301         self.failUnlessEqual(field.read_permission, View)
00302         self.failUnlessEqual(field.write_permission, ModifyPortalContent)
00303         self.failUnlessEqual(field.generateMode, 'veVc')
00304         self.failUnlessEqual(field.force, '')
00305         self.failUnlessEqual(field.type, 'string')
00306         self.failUnless(isinstance(field.storage, AttributeStorage))
00307         self.failUnless(field.getLayerImpl('storage') == AttributeStorage())
00308         self.failUnlessEqual(field.validators, idValidator)
00309         self.failUnless(isinstance(field.widget, IdWidget))
00310         vocab = field.Vocabulary(dummy)
00311         self.failUnless(isinstance(vocab, DisplayList))
00312         self.failUnlessEqual(tuple(vocab), ())

Definition at line 313 of file atcttestcase.py.

00313 
00314     def test_relateditems(self):
00315         dummy = self._dummy
00316         field = dummy.getField('relatedItems')
00317 
00318         self.failUnless(ILayerContainer.isImplementedBy(field))
00319         self.failUnlessEqual(field.required, False)
00320         self.failUnlessEqual(field.default, None)
00321         self.failUnlessEqual(field.searchable, False)
00322         self.failUnlessEqual(getattr(field, 'primary', None), None)
00323         vocab = field.vocabulary
00324         self.failUnlessEqual(vocab, ())
00325         self.failUnlessEqual(field.enforceVocabulary, False)
00326         self.failUnlessEqual(field.multiValued, True)
00327         self.failUnlessEqual(field.isMetadata, True)
00328         self.failUnlessEqual(field.accessor, 'getRelatedItems')
00329         self.failUnlessEqual(field.mutator, 'setRelatedItems')
00330         self.failUnlessEqual(field.edit_accessor, 'getRawRelatedItems')
00331         self.failUnlessEqual(field.read_permission, View)
00332         self.failUnlessEqual(field.write_permission, ModifyPortalContent)
00333         self.failUnlessEqual(field.generateMode, 'veVc')
00334         self.failUnlessEqual(field.force, '')
00335         self.failUnlessEqual(field.type, 'reference')
00336         self.failUnless(isinstance(field.storage, AttributeStorage))
00337         self.failUnless(field.getLayerImpl('storage') == AttributeStorage())
00338         self.failUnlessEqual(field.validators, EmptyValidator)
00339         self.failUnless(isinstance(field.widget, ReferenceBrowserWidget))
00340         vocab = field.Vocabulary(dummy)
00341         self.failUnless(isinstance(vocab, DisplayList))
00342 

Definition at line 201 of file test_atdocument.py.

00201 
00202     def test_text_field_mutator_filename(self):
00203         dummy = self._dummy
00204         field = dummy.getField('text')
00205         mutator = field.getMutator(dummy)
00206         self.assertEquals(field.getFilename(dummy), '')
00207         self.assertEquals(field.getContentType(dummy), 'text/html')
00208         mutator('', filename='foo.txt')
00209         self.assertEquals(field.getFilename(dummy), 'foo.txt')
00210         self.assertEquals(field.getContentType(dummy), 'text/plain')

Definition at line 211 of file test_atdocument.py.

00211 
00212     def test_text_field_mutator_mime(self):
00213         dummy = self._dummy
00214         field = dummy.getField('text')
00215         mutator = field.getMutator(dummy)
00216         self.assertEquals(field.getFilename(dummy), '')
00217         self.assertEquals(field.getContentType(dummy), 'text/html')
00218         mutator('', mimetype='text/plain')
00219         self.assertEquals(field.getFilename(dummy), '')
00220         self.assertEquals(field.getContentType(dummy), 'text/plain')

Definition at line 231 of file test_atdocument.py.

00231 
00232     def test_text_field_mutator_none_filename(self):
00233         dummy = self._dummy
00234         field = dummy.getField('text')
00235         mutator = field.getMutator(dummy)
00236         self.assertEquals(field.getFilename(dummy), '')
00237         self.assertEquals(field.getContentType(dummy), 'text/html')
00238         mutator('', filename=None)
00239         self.assertEquals(field.getFilename(dummy), '')
00240         self.assertEquals(field.getContentType(dummy), 'text/plain')

Definition at line 221 of file test_atdocument.py.

00221 
00222     def test_text_field_mutator_none_mime(self):
00223         dummy = self._dummy
00224         field = dummy.getField('text')
00225         mutator = field.getMutator(dummy)
00226         self.assertEquals(field.getFilename(dummy), '')
00227         self.assertEquals(field.getContentType(dummy), 'text/html')
00228         mutator('', mimetype=None)
00229         self.assertEquals(field.getFilename(dummy), '')
00230         self.assertEquals(field.getContentType(dummy), 'text/plain')

Definition at line 241 of file test_atdocument.py.

00241 
00242     def test_text_setEmptyText(self):
00243         dummy = self._dummy
00244         field = dummy.getField('text')
00245 
00246         # set text to a non-trivial value
00247         mutator = field.getMutator(dummy)
00248         mutator('Hello World!')
00249 
00250         # now, set an empty text
00251         mutator('')
00252 
00253         # verify that text is indeed empty
00254         accessor = field.getAccessor(dummy)
00255         self.assertEquals(accessor(), '')
        

Definition at line 256 of file test_atdocument.py.

00256 
00257     def test_textField(self):
00258         dummy = self._dummy
00259         field = dummy.getField('text')
00260 
00261         self.failUnless(ILayerContainer.isImplementedBy(field))
00262         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00263         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00264         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00265         self.failUnless(field.vocabulary == (),
00266                         'Value is %s' % str(field.vocabulary))
00267         self.failUnless(field.enforceVocabulary == 0,
00268                         'Value is %s' % field.enforceVocabulary)
00269         self.failUnless(field.multiValued == 0,
00270                         'Value is %s' % field.multiValued)
00271         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00272         self.failUnless(field.accessor == 'getText',
00273                         'Value is %s' % field.accessor)
00274         self.failUnless(field.mutator == 'setText',
00275                         'Value is %s' % field.mutator)
00276         self.failUnless(field.read_permission == View,
00277                         'Value is %s' % field.read_permission)
00278         self.failUnless(field.write_permission == ModifyPortalContent,
00279                         'Value is %s' % field.write_permission)
00280         self.failUnless(field.generateMode == 'veVc',
00281                         'Value is %s' % field.generateMode)
00282         self.failUnless(field.force == '', 'Value is %s' % field.force)
00283         self.failUnless(field.type == 'text', 'Value is %s' % field.type)
00284         self.failUnless(isinstance(field.storage, AnnotationStorage),
00285                         'Value is %s' % type(field.storage))
00286         self.failUnless(field.getLayerImpl('storage') == AnnotationStorage(migrate=True),
00287                         'Value is %s' % field.getLayerImpl('storage'))
00288         self.failUnless(ILayerContainer.isImplementedBy(field))
00289         self.failUnless(field.validators == NotRequiredTidyHTMLValidator,
00290                         'Value is %s' % repr(field.validators))
00291         self.failUnless(isinstance(field.widget, RichWidget),
00292                         'Value is %s' % id(field.widget))
00293         vocab = field.Vocabulary(dummy)
00294         self.failUnless(isinstance(vocab, DisplayList),
00295                         'Value is %s' % type(vocab))
00296         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00297 
00298         self.failUnless(field.primary == 1, 'Value is %s' % field.primary)
00299         self.failUnless(field.default_content_type is None,
00300                         'Value is %s' % field.default_content_type)
00301         self.failUnless(field.default_output_type == 'text/x-html-safe',
00302                         'Value is %s' % field.default_output_type)
00303 
00304         self.failUnless('text/html' in field.getAllowedContentTypes(dummy))
00305 
00306 tests.append(TestATDocumentFields)


Member Data Documentation

Definition at line 199 of file test_atdocument.py.


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