[CMF-checkins] CVS: CMF/CMFCore/tests - test_PortalFolder.py:1.20.18.1 test_TypesTool.py:1.18.6.1
Tres Seaver
tseaver@zope.com
Mon, 10 Mar 2003 18:50:28 -0500
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv2028/CMFCore/tests
Modified Files:
Tag: tseaver-ti_apb_redux-branch
test_PortalFolder.py test_TypesTool.py
Log Message:
Landing 'tseaver-typeinfo_as_apb-branch' against current HEAD, using
a new integration branch:
- Merged the branch and fixed up all conflicts; all tests pass.
- Updated all the 'factory_type_information' structures to make the
'action' key a TALES expression (e.g., "document_view" ->
"string:document_view").
Remaining TODOs:
- Write an external method for converting existing type info objects
(they all have dictionaries, instead of ActionInformation objects,
stored in the ZODB). Otherwise, all existing type info objects are
*toast*.
- Perhaps someone can think of a clever way to avoid the need for this
conversion?
=== CMF/CMFCore/tests/test_PortalFolder.py 1.20 => 1.20.18.1 ===
--- CMF/CMFCore/tests/test_PortalFolder.py:1.20 Sun Aug 4 18:59:12 2002
+++ CMF/CMFCore/tests/test_PortalFolder.py Mon Mar 10 18:49:55 2003
@@ -274,7 +274,8 @@
# Now, test overridden behavior
types_tool.Folder.addAction( id = 'mkdir'
, name = 'MKDIR handler'
- , action = 'grabbed'
+ , action = 'string:grabbed'
+ , condition = ''
, permission = ''
, category = 'folder'
, visible = 0
=== CMF/CMFCore/tests/test_TypesTool.py 1.18 => 1.18.6.1 ===
--- CMF/CMFCore/tests/test_TypesTool.py:1.18 Mon Jan 6 15:41:10 2003
+++ CMF/CMFCore/tests/test_TypesTool.py Mon Mar 10 18:49:55 2003
@@ -1,5 +1,4 @@
-from unittest import TestCase, TestSuite, makeSuite, main
-
+import unittest
import Zope
try:
from Interface.Verify import verifyClass
@@ -7,28 +6,29 @@
# for Zope versions before 2.6.0
from Interface import verify_class_implementation as verifyClass
-from Products.CMFCore.TypesTool import\
- FactoryTypeInformation as FTI,\
- ScriptableTypeInformation as STI,\
- TypesTool,Unauthorized
-
-from Products.CMFCore.PortalFolder import PortalFolder
-from Products.CMFCore.utils import _getViewFor
-
-from Products.CMFCore.tests.base.testcase import \
- SecurityRequestTest
-from Products.CMFCore.tests.base.security import \
- OmnipotentUser, UserWithRoles
-from Products.CMFCore.tests.base.dummy import \
- DummyObject, addDummy, DummyTypeInfo,\
- DummyFolder, DummyFTI
-
+from Acquisition import aq_base
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
+from webdav.NullResource import NullResource
from Products.PythonScripts.standard import url_quote
-from webdav.NullResource import NullResource
-from Acquisition import aq_base
+
+from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
+from Products.CMFCore.TypesTool import ScriptableTypeInformation as STI
+from Products.CMFCore.TypesTool import TypesTool
+from Products.CMFCore.TypesTool import Unauthorized
+
+from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.utils import _getViewFor
+
+from Products.CMFCore.tests.base.testcase import SecurityRequestTest
+from Products.CMFCore.tests.base.security import OmnipotentUser
+from Products.CMFCore.tests.base.security import UserWithRoles
+from Products.CMFCore.tests.base.dummy import DummyObject
+from Products.CMFCore.tests.base.dummy import addDummy
+from Products.CMFCore.tests.base.dummy import DummyTypeInfo
+from Products.CMFCore.tests.base.dummy import DummyFolder
+from Products.CMFCore.tests.base.dummy import DummyFTI
class TypesToolTests( SecurityRequestTest ):
@@ -40,7 +40,7 @@
root._setObject( 'portal_types', TypesTool() )
tool = root.portal_types
tool._setObject( 'Dummy Content', DummyFTI )
-
+
def test_processActions( self ):
"""
Are the correct, permitted methods returned for actions?
@@ -77,7 +77,8 @@
meta_types[factype['name']]=1
# The url_quote below is necessary 'cos of the one in
# main.dtml. Could be removed once that is gone.
- self.failIf(type(aq_base(tool.unrestrictedTraverse(url_quote(factype['action'])))) is NullResource)
+ act = tool.unrestrictedTraverse(url_quote(factype['action']))
+ self.failIf(type(aq_base(act)) is NullResource)
# Check the ones we're expecting are there
self.failUnless(meta_types.has_key('Scriptable Type Information'))
@@ -93,7 +94,7 @@
verifyClass(IActionProvider, TypesTool)
-class TypeInfoTests( TestCase ):
+class TypeInfoTests( unittest.TestCase ):
def test_construction( self ):
ti = self._makeInstance( 'Foo'
@@ -164,60 +165,53 @@
ACTION_LIST = \
( { 'id' : 'view'
, 'name' : 'View'
- , 'action' : 'foo_view'
+ , 'action' : 'string:foo_view'
, 'permissions' : ( 'View', )
, 'category' : 'object'
, 'visible' : 1
}
, { 'name' : 'Edit' # Note: No ID passed
- , 'action' : 'foo_edit'
+ , 'action' : 'string:foo_edit'
, 'permissions' : ( 'Modify', )
, 'category' : 'object'
, 'visible' : 1
}
, { 'name' : 'Object Properties' # Note: No ID passed
- , 'action' : 'foo_properties'
+ , 'action' : 'string:foo_properties'
, 'permissions' : ( 'Modify', )
, 'category' : 'object'
, 'visible' : 1
}
, { 'id' : 'slot'
- , 'action' : 'foo_slot'
+ , 'action' : 'string:foo_slot'
, 'category' : 'object'
, 'visible' : 0
}
)
- def _ripActionValues( self, key, actions ):
- return filter( None, map( lambda x, key=key: x.get( key, None )
- , actions
- ) )
-
def test_listActions( self ):
ti = self._makeInstance( 'Foo' )
- self.failIf( ti.getActions() )
+ self.failIf( ti.listActions() )
ti = self._makeInstance( 'Foo', actions=self.ACTION_LIST )
- actions = ti.getActions()
+ actions = ti.listActions()
self.failUnless( actions )
- ids = self._ripActionValues( 'id', actions )
+ ids = [ x.getId() for x in actions ]
self.failUnless( 'view' in ids )
self.failUnless( 'edit' in ids )
self.failUnless( 'objectproperties' in ids )
self.failUnless( 'slot' in ids )
- names = self._ripActionValues( 'name', actions )
+ names = [ x.Title() for x in actions ]
self.failUnless( 'View' in names )
self.failUnless( 'Edit' in names )
self.failUnless( 'Object Properties' in names )
self.failIf( 'slot' in names )
- self.failIf( 'Slot' in names )
+ self.failUnless( 'Slot' in names )
- visible = filter( None, map( lambda x:
- x.get( 'visible', 0 ) and x['id']
- , actions ) )
+ visible = [ x.getId() for x in actions if x.getVisibility() ]
self.failUnless( 'view' in visible )
self.failUnless( 'edit' in visible )
self.failUnless( 'objectproperties' in visible )
@@ -297,7 +291,7 @@
verifyClass(ITypeInformation, STI)
-class FTIConstructionTests( TestCase ):
+class FTIConstructionTests( unittest.TestCase ):
def setUp( self ):
noSecurityManager()
@@ -341,7 +335,7 @@
self.failIf( ti.isConstructionAllowed( folder ) )
-class FTIConstructionTests_w_Roles( TestCase ):
+class FTIConstructionTests_w_Roles( unittest.TestCase ):
def tearDown( self ):
noSecurityManager()
@@ -435,13 +429,13 @@
def test_suite():
- return TestSuite((
- makeSuite(TypesToolTests),
- makeSuite(FTIDataTests),
- makeSuite(STIDataTests),
- makeSuite(FTIConstructionTests),
- makeSuite(FTIConstructionTests_w_Roles),
+ return unittest.TestSuite((
+ unittest.makeSuite(TypesToolTests),
+ unittest.makeSuite(FTIDataTests),
+ unittest.makeSuite(STIDataTests),
+ unittest.makeSuite(FTIConstructionTests),
+ unittest.makeSuite(FTIConstructionTests_w_Roles),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')