Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def test_searchableText
def test_searchableTextUsesIndexMethod
def test_authenticatedContentType

Private Attributes

 _dummy

Detailed Description

Definition at line 68 of file test_baseobject.py.


Member Function Documentation

Definition at line 70 of file test_baseobject.py.

00070 
00071     def afterSetUp(self):
00072         ATSiteTestCase.afterSetUp(self)
00073         self._dummy = mkDummyInContext(Dummy, oid='dummy', context=self.portal,
00074                                       schema=schema)
    
See https://dev.plone.org/archetypes/ticket/712

content_type should not be protected by a security declaration, as
it is usually an attribute. If a security declaration *is* set (in
BaseObject or one of it's base classes) non-anonymous access from
protected code (guarded_getattr) will fail.

Definition at line 116 of file test_baseobject.py.

00116 
00117     def test_authenticatedContentType(self):
00118         """See https://dev.plone.org/archetypes/ticket/712
00119         
00120         content_type should not be protected by a security declaration, as
00121         it is usually an attribute. If a security declaration *is* set (in
00122         BaseObject or one of it's base classes) non-anonymous access from
00123         protected code (guarded_getattr) will fail.
00124         
00125         """
00126         from AccessControl.unauthorized import Unauthorized
00127         from AccessControl.Permissions import view
00128         from AccessControl.ZopeGuards import guarded_getattr
00129         
00130         dummy = self._dummy
00131         dummy.manage_permission(view, ('Manager',), False)
00132         # dummy.content_type in a Python Script
00133         self.assertRaises(Unauthorized, guarded_getattr, dummy, 'content_type')
00134         
00135         self.setRoles(('Manager',))
00136         # dummy.content_type in a Python Script
00137         self.assertEqual(guarded_getattr(dummy, 'content_type'), 'text/html')
00138         

Here is the call graph for this function:

Fix bug [ 951955 ] BaseObject/SearchableText and list of Unicode stuffs

Definition at line 75 of file test_baseobject.py.

00075 
00076     def test_searchableText(self):
00077         """
00078         Fix bug [ 951955 ] BaseObject/SearchableText and list of Unicode stuffs
00079         """
00080         dummy = self._dummy
00081 
00082         # Set a multiple field
00083         dummy.setMULTIPLEFIELD(['1','2'])
00084         searchable = dummy.SearchableText()
00085 
00086         self.failUnless(isinstance(searchable, basestring))
00087         self.assertEquals(searchable, '1 2 Option 1 : printemps Option 2 : \xc3\xa9t\xc3\xa9')
00088 
00089         dummy.setMULTIPLEFIELD(['3','4'])
00090         searchable = dummy.SearchableText()
00091 
00092         self.assertEquals(searchable, '3 4 Option 3 : automne option3')

See http://dev.plone.org/archetypes/ticket/645

We want SearchableText to use the ``index_method`` attribute
of fields to determine which is the accessor it should use
while gathering values.

Definition at line 93 of file test_baseobject.py.

00093 
00094     def test_searchableTextUsesIndexMethod(self):
00095         """See http://dev.plone.org/archetypes/ticket/645
00096 
00097         We want SearchableText to use the ``index_method`` attribute
00098         of fields to determine which is the accessor it should use
00099         while gathering values.
00100         """
00101         dummy = self._dummy
00102         
00103         # This is where we left off in the previous test
00104         dummy.setMULTIPLEFIELD(['1','2'])
00105         searchable = dummy.SearchableText()
00106         self.failUnless(searchable.startswith('1 2 Option 1 : printemps'))
00107 
00108         # Now we set another index_method and expect it to be used:
00109         dummy.getField('MULTIPLEFIELD').index_method = 'myMethod'
00110         def myMethod(self):
00111             return "What do you expect of a Dummy?"
00112         Dummy.myMethod = myMethod
00113         searchable = dummy.SearchableText()
00114         self.failUnless(searchable.startswith("What do you expect of a Dummy"))
00115         del Dummy.myMethod
        

Member Data Documentation

Definition at line 72 of file test_baseobject.py.


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