[CMF-checkins] CVS: CMF/CMFCore/tests - test_ActionInformation.py:1.1.2.1 test_ActionsTool.py:1.1.2.2 test_all.py:1.6.14.2

Andrew Sawyers andrew@zope.com
Thu, 3 Jan 2002 17:43:18 -0500


Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv32579/CMFCore/tests

Modified Files:
      Tag: andrew_ttw_actions-branch
	test_ActionsTool.py test_all.py 
Added Files:
      Tag: andrew_ttw_actions-branch
	test_ActionInformation.py 
Log Message:

*Factored out ActionInformation tests from ActionTool tests
*Fixed bug in ActionTool tests
*updated test_all.py


=== Added File CMF/CMFCore/tests/test_ActionInformation.py ===
import unittest
from Products.CMFCore.ActionsTool import *
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import Expression

class ActionInformationTests(unittest.TestCase):
    
    def test_basic_construction(self):
        ai = ActionInformation(id='view'
                              )
        self.assertEqual(ai.getId(), 'view')
        self.assertEqual(ai.Title(), 'view')
        self.assertEqual(ai.Description(), '')
        self.assertEqual(ai.getCondition(), '')
        self.assertEqual(ai.getActionExpression(), '')
        self.assertEqual(ai.getPermissions(), ())

    def test_construction_with_Expressions(self):
        ai = ActionInformation(id='view'
                             , title='View'
                             , action=Expression(
             text='view')
                             , condition=Expression(
             text='member'))
        self.assertEqual(ai.getId(), 'view')
        self.assertEqual(ai.Title(), 'View')
        self.assertEqual(ai.Description(), '')
        self.assertEqual(ai.getCondition(), 'member')
        self.assertEqual(ai.getActionExpression(), 'view')
        self.assertEqual(ai.getPermissions(), ())
        

def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(ActionInformationTests))
    return suite

def run():
    unittest.TextTestRunner().run(test_suite())

if __name__ == '__main__':
    run()


=== CMF/CMFCore/tests/test_ActionsTool.py 1.1.2.1 => 1.1.2.2 ===
 from AccessControl import SecurityManager
 from Products.CMFCore.ActionsTool import *
-from Products.CMFCore.ActionInformation import ActionInformation
-from Products.CMFCore.Expression import Expression
-from Products.CMFCore.PortalContent import PortalContent
-from Products.CMFCore.CMFCorePermissions import AddPortalContent, ManagePortal
+from Products.CMFCore.CMFCorePermissions import AddPortalContent
 from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
 from Products.CMFCore import utils
 import ZPublisher.HTTPRequest
@@ -37,36 +34,6 @@
             return 0
         return 1
 
-class OmnipotentUser( Acquisition.Implicit ):
-    """
-        Stubbed out manager for unit testing purposes.
-    """
-    def getId( self ):
-        return 'all_powerful_Oz'
-    
-    getUserName = getId
-
-    def allowed( self, object, object_roles=None ):
-        return 1
-
-class UserWithRoles( Acquisition.Implicit ):
-    """
-        Stubbed out manager for unit testing purposes.
-    """
-    def __init__( self, *roles ):
-        self._roles = roles
-
-    def getId( self ):
-        return 'high_roller'
-    
-    getUserName = getId
-
-    def allowed( self, object, object_roles=None ):
-        for orole in object_roles:
-            if orole in self._roles:
-                return 1
-        return 0
-
 class UnitTestUser( Acquisition.Implicit ):
     """
         Stubbed out manager for unit testing purposes.
@@ -101,8 +68,11 @@
         root.REQUEST = ZPublisher.HTTPRequest.HTTPRequest( None, env, None )
         
         root._setObject( 'portal_actions', ActionsTool() )
-        tool = root.portal_actions
-        tool.action_providers = ('portal_actions')
+        self.tool = tool = root.portal_actions
+        tool.action_providers = ('portal_actions',)
+
+    def test_actionProviders(self):
+        tool = self.tool
         self.assertEqual(tool.listActionProviders(), ('portal_actions',))
 
     def tearDown( self ):
@@ -111,37 +81,9 @@
         noSecurityManager()
         SecurityManager.setSecurityPolicy(self._oldPolicy)
 
-class ActionInformationTests(unittest.TestCase):
-    
-    def test_basic_construction(self):
-        ai = ActionInformation(id='view'
-                              )
-        self.assertEqual(ai.getId(), 'view')
-        self.assertEqual(ai.Title(), 'view')
-        self.assertEqual(ai.Description(), '')
-        self.assertEqual(ai.getCondition(), '')
-        self.assertEqual(ai.getActionExpression(), '')
-        self.assertEqual(ai.getPermissions(), ())
-
-    def test_construction_with_Expressions(self):
-        ai = ActionInformation(id='view'
-                             , title='View'
-                             , action=Expression(
-             text='view')
-                             , condition=Expression(
-             text='member'))
-        self.assertEqual(ai.getId(), 'view')
-        self.assertEqual(ai.Title(), 'View')
-        self.assertEqual(ai.Description(), '')
-        self.assertEqual(ai.getCondition(), 'member')
-        self.assertEqual(ai.getActionExpression(), 'view')
-        self.assertEqual(ai.getPermissions(), ())
-        
-
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(ActionsToolTests))
-    suite.addTest(unittest.makeSuite(ActionInformationTests))
     return suite
 
 def run():


=== CMF/CMFCore/tests/test_all.py 1.6.14.1 => 1.6.14.2 ===
 from Products.CMFCore.tests import test_TypesTool
 from Products.CMFCore.tests import test_ActionsTool
+from Products.CMFCore.tests import test_ActionInformation
 from Products.CMFCore.tests import test_CatalogTool
 
 def test_suite():
@@ -12,6 +13,7 @@
     suite.addTest( test_PortalFolder.test_suite() )
     suite.addTest( test_TypesTool.test_suite() )
     suite.addTest( test_ActionsTool.test_suite()  )
+    suite.addTest( test_ActionInformation.test_suite() )
     suite.addTest( test_CatalogTool.test_suite() )
     return suite