[CMF-checkins] CVS: CMF/CMFSetup/tests - test_typeinfo.py:1.12 test_workflow.py:1.26

Martijn Pieters mj at zopatista.com
Wed Nov 10 08:12:51 EST 2004


Update of /cvs-repository/CMF/CMFSetup/tests
In directory cvs.zope.org:/tmp/cvs-serv11006/tests

Modified Files:
	test_typeinfo.py test_workflow.py 
Log Message:
Oops, checked into the HEAD instead of into the branch. Mea Culpa.


=== CMF/CMFSetup/tests/test_typeinfo.py 1.11 => 1.12 ===
--- CMF/CMFSetup/tests/test_typeinfo.py:1.11	Wed Nov 10 08:05:48 2004
+++ CMF/CMFSetup/tests/test_typeinfo.py	Wed Nov 10 08:12:21 2004
@@ -110,6 +110,7 @@
                    , 'allowed_content_types'
                    , 'allow_discussion'
                    , 'global_allow'
+                   , 'aliases'
                    ):
             self.assertEqual( found[ key ], expected[ key ] )
 
@@ -155,6 +156,7 @@
                    , 'allowed_content_types'
                    , 'allow_discussion'
                    , 'global_allow'
+                   , 'aliases'
                    ):
             self.assertEqual( found[ key ], expected[ key ] )
 
@@ -305,6 +307,7 @@
         info = info_list[ 0 ]
         self.assertEqual( info[ 'id' ], 'foo' )
         self.assertEqual( info[ 'title' ], 'Foo' )
+        self.assertEqual( len( info[ 'aliases' ] ), 2 )
 
     def test_parseTypeXML_STI( self ):
 
@@ -319,6 +322,7 @@
         info = info_list[ 0 ]
         self.assertEqual( info[ 'id' ], 'bar' )
         self.assertEqual( info[ 'title' ], 'Bar' )
+        self.assertEqual( len( info[ 'aliases' ] ), 2 )
 
     def test_parseTypeXML_actions( self ):
 
@@ -350,6 +354,9 @@
              , 'allowed_content_types'  : ()
              , 'allow_discussion'       : False
              , 'global_allow'           : False
+             , 'aliases'                : { '(Default)' : 'foo_view'
+                                          , 'view'      : 'foo_view'
+                                          }
              , 'actions'        :
                 ( { 'id'            : 'view'
                   , 'name'          : 'View'
@@ -380,6 +387,9 @@
              , 'allowed_content_types'  : ( 'foo', )
              , 'allow_discussion'       : True
              , 'global_allow'           : True
+             , 'aliases'                : { '(Default)' : 'bar_view'
+                                          , 'view'      : 'bar_view'
+                                          }
              , 'actions'        :
                 ( { 'id'            : 'view'
                   , 'name'          : 'View'
@@ -448,6 +458,10 @@
    allow_discussion="False"
    global_allow="False" >
   <description>Foo things</description>
+  <aliases>
+   <alias from="(Default)" to="foo_view" />
+   <alias from="view" to="foo_view" />
+  </aliases>
   <action
      action_id="view"
      title="View"
@@ -493,6 +507,10 @@
    global_allow="True" >
   <description>Bar things</description>
   <allowed_content_type>foo</allowed_content_type>
+  <aliases>
+   <alias from="(Default)" to="bar_view" />
+   <alias from="view" to="bar_view" />
+  </aliases>
   <action
      action_id="view"
      title="View"


=== CMF/CMFSetup/tests/test_workflow.py 1.25 => 1.26 ===
--- CMF/CMFSetup/tests/test_workflow.py:1.25	Wed Nov 10 08:05:48 2004
+++ CMF/CMFSetup/tests/test_workflow.py	Wed Nov 10 08:12:21 2004
@@ -69,14 +69,15 @@
 
 class _GuardChecker:
 
-    def _genGuardProps( self, permissions, roles, expr ):
+    def _genGuardProps( self, permissions, roles, groups, expr ):
 
         return { 'guard_permissions'   : '; '.join( permissions )
                , 'guard_roles'         : '; '.join( roles )
+               , 'guard_groups'        : '; '.join( groups )
                , 'guard_expr'          : expr
                }
 
-    def _assertGuard( self, info, permissions, roles, expr ):
+    def _assertGuard( self, info, permissions, roles, groups, expr ):
 
         self.assertEqual( len( info[ 'guard_permissions' ] )
                         , len( permissions ) )
@@ -90,6 +91,12 @@
         for expected in roles:
             self.failUnless( expected in info[ 'guard_roles' ] )
 
+        self.assertEqual( len( info[ 'guard_groups' ] )
+                        , len( groups ) )
+
+        for expected in groups:
+            self.failUnless( expected in info[ 'guard_groups' ] )
+
         self.assertEqual( info[ 'guard_expr' ], expr )
 
 
@@ -118,7 +125,7 @@
             variable = dcworkflow.variables._getOb( id )
 
             ( descr, def_val, def_exp, for_cat, for_stat, upd_alw
-            ) = args[ :-3 ]
+            ) = args[ :-4 ]
 
             variable.setProperties( description=args[0]
                                   , default_value=args[1]
@@ -126,11 +133,13 @@
                                   , for_catalog=args[3]
                                   , for_status=args[4]
                                   , update_always=args[5]
-                                  , props=self._genGuardProps( *args[ -3: ] )
+                                  , props=self._genGuardProps( *args[ -4: ] )
                                   )
 
     def _initStates( self, dcworkflow ):
 
+        dcworkflow.groups = _WF_GROUPS
+
         for k, v in _WF_STATES.items():
 
             dcworkflow.states.addState( k )
@@ -150,6 +159,12 @@
                                    )
             faux_request = {}
 
+            for group_id, roles in v[ 4 ]:
+                for role in roles:
+                    faux_request[ '%s|%s' % ( group_id, role ) ] = True
+
+            state.setGroups( REQUEST=faux_request )
+
             for k, v in v[ 5 ].items():
                 state.addVariable( k, v )
 
@@ -169,7 +184,7 @@
                                     , actbox_name=v[ 6 ]
                                     , actbox_url=v[ 7 ]
                                     , actbox_category=v[ 8 ]
-                                    , props=self._genGuardProps( *v[ -3: ] )
+                                    , props=self._genGuardProps( *v[ -4: ] )
                                     )
 
             for k, v in v[ 9 ].items():
@@ -184,7 +199,7 @@
 
             worklist.title = v[ 0 ]
 
-            props=self._genGuardProps( *v[ -3: ] )
+            props=self._genGuardProps( *v[ -4: ] )
 
             for var_id, matches in v[ 2 ].items():
                 props[ 'var_match_%s' % var_id ] = ';'.join( matches )
@@ -305,7 +320,7 @@
             self.assertEqual( info[ 'for_status' ], expected[ 4 ] )
             self.assertEqual( info[ 'update_always' ], expected[ 5 ] )
 
-            self._assertGuard( info, *expected[ -3: ] )
+            self._assertGuard( info, *expected[ -4: ] )
 
     def test_getWorkflowInfo_dcworkflow_states( self ):
 
@@ -355,6 +370,12 @@
                 for ep_role in ep_roles:
                     self.failUnless( ep_role in fp[ 'roles' ] )
 
+            groups = info[ 'groups' ]
+            self.assertEqual( len( groups ), len( expected[ 4 ] ) )
+
+            for i in range( len( groups ) ):
+                self.assertEqual( groups[ i ], expected[ 4 ][ i ] )
+
             variables = info[ 'variables' ]
             self.assertEqual( len( variables ), len( expected[ 5 ] ) )
 
@@ -417,7 +438,7 @@
                 self.assertEqual( v_info[ 'expr' ]
                                 , expected[ 9 ][ v_info[ 'name' ] ] )
 
-            self._assertGuard( info, *expected[ -3: ] )
+            self._assertGuard( info, *expected[ -4: ] )
 
     def test_getWorkflowInfo_dcworkflow_worklists( self ):
 
@@ -460,7 +481,7 @@
                 for e_value in e_values:
                     self.failUnless( e_value in values )
 
-            self._assertGuard( info, *expected[ -3: ] )
+            self._assertGuard( info, *expected[ -4: ] )
 
     def test_getWorkflowInfo_dcworkflow_scripts( self ):
 
@@ -918,6 +939,8 @@
 
             self.assertEqual( tuple( state[ 'transitions' ] ), expected[ 2 ] )
             self.assertEqual( state[ 'permissions' ], expected[ 3 ] )
+            self.assertEqual( tuple( state[ 'groups' ] )
+                            , tuple( expected[ 4 ] ) )
 
             for k, v_info in state[ 'variables' ].items():
 
@@ -996,7 +1019,9 @@
                             , expected[ 10 ] )
             self.assertEqual( tuple( guard.get( 'roles', () ) )
                             , expected[ 11 ] )
-            self.assertEqual( guard.get( 'expression', '' ), expected[ 12 ] )
+            self.assertEqual( tuple( guard.get( 'groups', () ) )
+                            , expected[ 12 ] )
+            self.assertEqual( guard.get( 'expression', '' ), expected[ 13 ] )
 
     def test_parseWorkflowXML_normal_variables( self ):
 
@@ -1071,7 +1096,9 @@
                             , expected[ 6 ] )
             self.assertEqual( tuple( guard.get( 'roles', () ) )
                             , expected[ 7 ] )
-            self.assertEqual( guard.get( 'expression', '' ), expected[ 8 ] )
+            self.assertEqual( tuple( guard.get( 'groups', () ) )
+                            , expected[ 8 ] )
+            self.assertEqual( guard.get( 'expression', '' ), expected[ 9 ] )
 
     def test_parseWorkflowXML_normal_worklists( self ):
 
@@ -1130,7 +1157,9 @@
                             , expected[ 6 ] )
             self.assertEqual( tuple( guard.get( 'roles', () ) )
                             , expected[ 7 ] )
-            self.assertEqual( guard.get( 'expression', '' ), expected[ 8 ] )
+            self.assertEqual( tuple( guard.get( 'groups', () ) )
+                            , expected[ 8 ] )
+            self.assertEqual( guard.get( 'expression', '' ), expected[ 9 ] )
 
     def test_parseWorkflowXML_normal_permissions( self ):
 
@@ -1222,6 +1251,11 @@
 , 'Restore expired content'
 )
 
+_WF_GROUPS = \
+( 'Content_owners'
+, 'Content_assassins'
+)
+
 _WF_VARIABLES = \
 { 'when_opened':  ( 'Opened when'
                   , ''
@@ -1231,6 +1265,7 @@
                   , True
                   , ( 'Query history', 'Open content for modifications' )
                   , ()
+                  , ()
                   , ""
                   )
 , 'when_expired': ( 'Expired when'
@@ -1241,6 +1276,7 @@
                   , True
                   , ( 'Query history', 'Open content for modifications' )
                   , ()
+                  , ()
                   , ""
                   )
 , 'killed_by':    ( 'Killed by'
@@ -1251,6 +1287,7 @@
                   , True
                   , ()
                   , ( 'Hangman', 'Sherrif' )
+                  , ()
                   , ""
                   )
 }
@@ -1299,6 +1336,7 @@
              , { 'when_opened' : 'object/ZopeTime' }
              , ( 'Open content for modifications', )
              , ()
+             , ()
              , ""
              )
 , 'close':   ( 'Close'
@@ -1313,6 +1351,7 @@
              , {}
              , ()
              , ( 'Owner', 'Manager' )
+             , ()
              , ""
              )
 , 'kill':    ( 'Kill'
@@ -1327,6 +1366,7 @@
              , { 'killed_by' : 'string:${user/getId}' }
              , ()
              , ()
+             , ( 'Content_assassins', )
              , ""
              )
 , 'expire':  ( 'Expire'
@@ -1341,6 +1381,7 @@
              , { 'when_expired' : 'object/ZopeTime' }
              , ()
              , ()
+             , ()
              , "python: object.expiration() <= object.ZopeTime()"
              )
 }
@@ -1354,6 +1395,7 @@
                     , 'workflow'
                     , ( 'Restore expired content', )
                     , ()
+                    , ()
                     , ""
                     )
 , 'alive_list':     ( 'Alive'
@@ -1364,6 +1406,7 @@
                     , 'workflow'
                     , ( 'Restore expired content', )
                     , ()
+                    , ()
                     , ""
                     )
 }
@@ -1600,6 +1643,9 @@
    <permission-role>Owner</permission-role>
    <permission-role>Manager</permission-role>
   </permission-map>
+  <group-map name="Content_owners">
+   <group-role>Owner</group-role>
+  </group-map>
   <assignment
     name="is_closed"
     type="bool">False</assignment>
@@ -1649,6 +1695,7 @@
     category="workflow"
     url="string:${object_url}/kill_object">Kill</action>
   <guard>
+   <guard-group>Content_assassins</guard-group>
   </guard>
   <assignment
     name="killed_by">string:${user/getId}</assignment>
@@ -2089,7 +2136,8 @@
 
             self.assertEqual( guard.permissions, expected[ 6 ] )
             self.assertEqual( guard.roles, expected[ 7 ] )
-            self.assertEqual( guard.getExprText(), expected[ 8 ] )
+            self.assertEqual( guard.groups, expected[ 8 ] )
+            self.assertEqual( guard.getExprText(), expected[ 9 ] )
 
     def test_from_empty_dcworkflow_workflow_states( self ):
 
@@ -2130,6 +2178,17 @@
                 for role in p_info[ 'roles' ]:
                     self.failIf( role not in p_expected )
 
+            group_roles = state.group_roles or {}
+            self.assertEqual( len( group_roles ), len( expected[ 4 ] ) )
+
+            for group_id, exp_roles in expected[ 4 ]:
+
+                self.assertEqual( len( state.getGroupInfo( group_id ) )
+                                , len( exp_roles ) )
+
+                for role in state.getGroupInfo( group_id ):
+                    self.failUnless( role in exp_roles )
+
             self.assertEqual( len( state.getVariableValues() )
                             , len( expected[ 5 ] ) )
 
@@ -2176,7 +2235,8 @@
 
             self.assertEqual( guard.permissions, expected[ 10 ] )
             self.assertEqual( guard.roles, expected[ 11 ] )
-            self.assertEqual( guard.getExprText(), expected[ 12 ] )
+            self.assertEqual( guard.groups, expected[ 12 ] )
+            self.assertEqual( guard.getExprText(), expected[ 13 ] )
 
     def test_from_empty_dcworkflow_workflow_worklists( self ):
 
@@ -2217,7 +2277,8 @@
 
             self.assertEqual( guard.permissions, expected[ 6 ] )
             self.assertEqual( guard.roles, expected[ 7 ] )
-            self.assertEqual( guard.getExprText(), expected[ 8 ] )
+            self.assertEqual( guard.groups, expected[ 8 ] )
+            self.assertEqual( guard.getExprText(), expected[ 9 ] )
 
     def test_from_empty_dcworkflow_workflow_scripts( self ):
 



More information about the CMF-checkins mailing list