Back to index

plone3  3.1.7
Public Member Functions
Archetypes.tests.test_default_mimetypes.TestDefaultMimeTypes Class Reference
Inheritance diagram for Archetypes.tests.test_default_mimetypes.TestDefaultMimeTypes:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.tests.test_default_mimetypes.TestDefaultMimeTypes:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_ATDocumentDefaultType

Detailed Description

Definition at line 6 of file test_default_mimetypes.py.


Member Function Documentation

Definition at line 8 of file test_default_mimetypes.py.

00008 
00009     def test_ATDocumentDefaultType(self):
00010         self.loginAsPortalOwner()
00011         # we create a new document: 
00012         self.portal.invokeFactory('Document', id='testdoc', title='TestDocument')
00013         obj = self.portal.testdoc
00014         # its text field should have the site wide default 'text/html'
00015         textfield = obj.getField('text')
00016         self.assertEqual(textfield.getContentType(obj), 'text/html')
00017         # but not the description field:
00018         descriptionfield = obj.getField('description')
00019         self.assertEqual(descriptionfield.getContentType(obj), 'text/plain')
00020         
00021         # then we change the sitewide default: 
00022         from Products.Archetypes.mimetype_utils import setDefaultContentType
00023         setDefaultContentType(self.portal, "text/x-web-markdown")
00024         self.assertEqual(textfield.getContentType(obj), 'text/html')
00025         # this should only affect new objects:
00026         self.failIf(textfield.getContentType(obj) == 'text/x-web-markdown')
00027         self.portal.invokeFactory('Document', id='testdoc2', title='TestDocument with new default')
00028         second_object = self.portal.testdoc2
00029         second_field = second_object.getField('text')
00030         self.failUnless(second_field.getContentType(second_object) == 'text/x-web-markdown')

Here is the call graph for this function:


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