Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
CMFCore.tests.test_TypesTool.TypeInfoTests Class Reference
Inheritance diagram for CMFCore.tests.test_TypesTool.TypeInfoTests:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_construction
def test_allowType
def test_GlobalHide
def test_allowDiscussion
def test_listActions
def test_MethodAliases_methods

Public Attributes

 tool

Private Member Functions

def _makeTypesTool
def _makeAndSetInstance
def _checkContentTI
def _checkFolderTI

Detailed Description

Definition at line 173 of file test_TypesTool.py.


Member Function Documentation

Definition at line 284 of file test_TypesTool.py.

00284 
00285     def _checkContentTI(self, ti):
00286         wanted_aliases = { 'view': 'dummy_view', '(Default)': 'dummy_view' }
00287         wanted_actions_text0 = 'string:${object_url}/dummy_view'
00288         wanted_actions_text1 = 'string:${object_url}/dummy_edit_form'
00289         wanted_actions_text2 = 'string:${object_url}/metadata_edit_form'
00290 
00291         self.failUnless( isinstance( ti._actions[0], ActionInformation ) )
00292         self.assertEqual( len( ti._actions ), 3 )
00293         self.assertEqual(ti._aliases, wanted_aliases)
00294         self.assertEqual(ti._actions[0].action.text, wanted_actions_text0)
00295         self.assertEqual(ti._actions[1].action.text, wanted_actions_text1)
00296         self.assertEqual(ti._actions[2].action.text, wanted_actions_text2)
00297 
00298         action0 = ti._actions[0]
00299         self.assertEqual( action0.getId(), 'view' )
00300         self.assertEqual( action0.Title(), 'View' )
00301         self.assertEqual( action0.getActionExpression(), wanted_actions_text0 )
00302         self.assertEqual( action0.getCondition(), '' )
00303         self.assertEqual( action0.getPermissions(), ( 'View', ) )
00304         self.assertEqual( action0.getCategory(), 'object' )
00305         self.assertEqual( action0.getVisibility(), 1 )

Definition at line 306 of file test_TypesTool.py.

00306 
00307     def _checkFolderTI(self, ti):
00308         wanted_aliases = { 'view': '(Default)' }
00309         wanted_actions_text0 = 'string:${object_url}'
00310         wanted_actions_text1 = 'string:${object_url}/dummy_edit_form'
00311         wanted_actions_text2 = 'string:${object_url}/folder_localrole_form'
00312 
00313         self.failUnless( isinstance( ti._actions[0], ActionInformation ) )
00314         self.assertEqual( len( ti._actions ), 3 )
00315         self.assertEqual(ti._aliases, wanted_aliases)
00316         self.assertEqual(ti._actions[0].action.text, wanted_actions_text0)
00317         self.assertEqual(ti._actions[1].action.text, wanted_actions_text1)
00318         self.assertEqual(ti._actions[2].action.text, wanted_actions_text2)
00319 

def CMFCore.tests.test_TypesTool.TypeInfoTests._makeAndSetInstance (   self,
  id,
  kw 
) [private]

Definition at line 198 of file test_TypesTool.py.

00198 
00199     def _makeAndSetInstance(self, id, **kw):
00200         tool = self.tool
00201         t = self._makeInstance(id, **kw)
00202         tool._setObject(id,t)
00203         return tool[id]

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 175 of file test_TypesTool.py.

00175 
00176     def _makeTypesTool(self):
00177         from Products.CMFCore.TypesTool import TypesTool
00178 
00179         return TypesTool()

Here is the caller graph for this function:

Definition at line 241 of file test_TypesTool.py.

00241 
00242     def test_allowDiscussion( self ):
00243         ti = self._makeInstance( 'Foo' )
00244         self.failIf( ti.allowDiscussion() )
00245 
00246         ti = self._makeInstance( 'Foo', allow_discussion=1 )
00247         self.failUnless( ti.allowDiscussion() )

Here is the call graph for this function:

Definition at line 204 of file test_TypesTool.py.

00204 
00205     def test_allowType( self ):
00206         self.tool = self._makeTypesTool()
00207         ti = self._makeAndSetInstance( 'Foo' )
00208         self.failIf( ti.allowType( 'Foo' ) )
00209         self.failIf( ti.allowType( 'Bar' ) )
00210 
00211         ti = self._makeAndSetInstance( 'Foo2', allowed_content_types=( 'Bar', ) )
00212         self.failUnless( ti.allowType( 'Bar' ) )
00213 
00214         ti = self._makeAndSetInstance( 'Foo3', filter_content_types=0 )
00215         self.failUnless( ti.allowType( 'Foo3' ) )

Definition at line 180 of file test_TypesTool.py.

00180 
00181     def test_construction( self ):
00182         ti = self._makeInstance( 'Foo'
00183                                , description='Description'
00184                                , meta_type='Foo'
00185                                , icon='foo.gif'
00186                                )
00187         self.assertEqual( ti.getId(), 'Foo' )
00188         self.assertEqual( ti.Title(), 'Foo' )
00189         self.assertEqual( ti.Description(), 'Description' )
00190         self.assertEqual( ti.Metatype(), 'Foo' )
00191         self.assertEqual( ti.getIcon(), 'foo.gif' )
00192         self.assertEqual( ti.immediate_view, '' )
00193 
00194         ti = self._makeInstance( 'Foo'
00195                                , immediate_view='foo_view'
00196                                )
00197         self.assertEqual( ti.immediate_view, 'foo_view' )

Here is the call graph for this function:

Definition at line 216 of file test_TypesTool.py.

00216 
00217     def test_GlobalHide( self ):
00218         self.tool = self._makeTypesTool()
00219         tnf = self._makeAndSetInstance( 'Folder', filter_content_types=0)
00220         taf = self._makeAndSetInstance( 'Allowing Folder'
00221                                       , allowed_content_types=( 'Hidden'
00222                                                               ,'Not Hidden'))
00223         tih = self._makeAndSetInstance( 'Hidden', global_allow=0)
00224         tnh = self._makeAndSetInstance( 'Not Hidden')
00225         # make sure we're normally hidden but everything else is visible
00226         self.failIf     ( tnf.allowType( 'Hidden' ) )
00227         self.failUnless ( tnf.allowType( 'Not Hidden') )
00228         # make sure we're available where we should be
00229         self.failUnless ( taf.allowType( 'Hidden' ) )
00230         self.failUnless ( taf.allowType( 'Not Hidden') )
00231         # make sure we're available in a non-content-type-filtered type
00232         # where we have been explicitly allowed
00233         taf2 = self._makeAndSetInstance( 'Allowing Folder2'
00234                                        , allowed_content_types=( 'Hidden'
00235                                                                , 'Not Hidden'
00236                                                                )
00237                                        , filter_content_types=0
00238                                        )
00239         self.failUnless ( taf2.allowType( 'Hidden' ) )
00240         self.failUnless ( taf2.allowType( 'Not Hidden') )

Here is the call graph for this function:

Definition at line 248 of file test_TypesTool.py.

00248 
00249     def test_listActions( self ):
00250         ti = self._makeInstance( 'Foo' )
00251         self.failIf( ti.listActions() )
00252 
00253         ti = self._makeInstance( **FTIDATA_ACTIONS[0] )
00254         actions = ti.listActions()
00255         self.failUnless( actions )
00256 
00257         ids = [ x.getId() for x in actions ]
00258         self.failUnless( 'view' in ids )
00259         self.failUnless( 'edit' in ids )
00260         self.failUnless( 'objectproperties' in ids )
00261         self.failUnless( 'slot' in ids )
00262 
00263         names = [ x.Title() for x in actions ]
00264         self.failUnless( 'View' in names )
00265         self.failUnless( 'Edit' in names )
00266         self.failUnless( 'Object Properties' in names )
00267         self.failIf( 'slot' in names )
00268         self.failUnless( 'Slot' in names )
00269 
00270         visible = [ x.getId() for x in actions if x.getVisibility() ]
00271         self.failUnless( 'view' in visible )
00272         self.failUnless( 'edit' in visible )
00273         self.failUnless( 'objectproperties' in visible )
00274         self.failIf( 'slot' in visible )

Here is the call graph for this function:

Definition at line 275 of file test_TypesTool.py.

00275 
00276     def test_MethodAliases_methods(self):
00277         ti = self._makeInstance( **FTIDATA_CMF15[0] )
00278         self.assertEqual( ti.getMethodAliases(), FTIDATA_CMF15[0]['aliases'] )
00279         self.assertEqual( ti.queryMethodID('view'), 'dummy_view' )
00280         self.assertEqual( ti.queryMethodID('view.html'), 'dummy_view' )
00281 
00282         ti.setMethodAliases( ti.getMethodAliases() )
00283         self.assertEqual( ti.getMethodAliases(), FTIDATA_CMF15[0]['aliases'] )

Here is the call graph for this function:


Member Data Documentation

Definition at line 205 of file test_TypesTool.py.


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