[CMF-checkins] CVS: CMF/CMFCore/tests - test_TypesTool.py:1.18.6.2
Tres Seaver
tseaver@zope.com
Tue, 11 Mar 2003 18:43:37 -0500
Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv21927/CMFCore/tests
Modified Files:
Tag: tseaver-ti_apb_redux-branch
test_TypesTool.py
Log Message:
- CMFCore/TypesTool.py:
o Force 'string:' prefix for "action" TALES expression when converting
actions from dictionaries.
- CMFCore/tests/test_TypesTool.py:
o Add explicit test of conversion from dictionary-based actions.
o Normalize wide lines.
=== CMF/CMFCore/tests/test_TypesTool.py 1.18.6.1 => 1.18.6.2 ===
--- CMF/CMFCore/tests/test_TypesTool.py:1.18.6.1 Mon Mar 10 18:49:55 2003
+++ CMF/CMFCore/tests/test_TypesTool.py Tue Mar 11 18:43:25 2003
@@ -136,9 +136,10 @@
def test_GlobalHide( self ):
self.tool = TypesTool()
tnf = self._makeAndSetInstance( 'Folder', filter_content_types=0)
- taf = self._makeAndSetInstance( 'Allowing Folder',
- allowed_content_types=('Hidden','Not Hidden'))
- tih = self._makeAndSetInstance( 'Hidden' ,global_allow=0)
+ taf = self._makeAndSetInstance( 'Allowing Folder'
+ , allowed_content_types=( 'Hidden'
+ ,'Not Hidden'))
+ tih = self._makeAndSetInstance( 'Hidden', global_allow=0)
tnh = self._makeAndSetInstance( 'Not Hidden')
# make sure we're normally hidden but everything else is visible
self.failIf ( tnf.allowType( 'Hidden' ) )
@@ -148,9 +149,12 @@
self.failUnless ( taf.allowType( 'Not Hidden') )
# make sure we're available in a non-content-type-filtered type
# where we have been explicitly allowed
- taf2 = self._makeAndSetInstance( 'Allowing Folder2',
- allowed_content_types=('Hidden','Not Hidden'),
- filter_content_types=0)
+ taf2 = self._makeAndSetInstance( 'Allowing Folder2'
+ , allowed_content_types=( 'Hidden'
+ , 'Not Hidden'
+ )
+ , filter_content_types=0
+ )
self.failUnless ( taf2.allowType( 'Hidden' ) )
self.failUnless ( taf2.allowType( 'Not Hidden') )
@@ -241,6 +245,37 @@
action = ti.getActionById( 'slot' )
self.assertEqual( action, 'foo_slot' )
+
+ def test__convertActions_from_dict( self ):
+
+ from Products.CMFCore.ActionInformation import ActionInformation
+
+ ti = self._makeInstance( 'Foo' )
+ ti._actions = ( { 'id' : 'bar'
+ , 'name' : 'Bar'
+ , 'action' : 'bar_action'
+ , 'permissions' : ( 'Bar permission', )
+ , 'category' : 'baz'
+ , 'visible' : 0
+ }
+ ,
+ )
+
+ actions = ti.listActions()
+ self.assertEqual( len( actions ), 1 )
+
+ action = actions[0]
+
+ self.failUnless( isinstance( action, ActionInformation ) )
+ self.assertEqual( action.getId(), 'bar' )
+ self.assertEqual( action.Title(), 'Bar' )
+ self.assertEqual( action.getActionExpression(), 'string:bar_action' )
+ self.assertEqual( action.getCondition(), '' )
+ self.assertEqual( action.getPermissions(), ( 'Bar permission', ) )
+ self.assertEqual( action.getCategory(), 'baz' )
+ self.assertEqual( action.getVisibility(), 0 )
+
+ self.failUnless( isinstance( ti._actions[0], ActionInformation ) )
class FTIDataTests( TypeInfoTests ):