[CMF-checkins] CVS: CMF/CMFCore/tests - test_ActionsTool.py:1.2.14.2

Chris Withers chrisw@nipltd.com
Mon, 11 Feb 2002 12:09:30 -0500


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

Modified Files:
      Tag: ChrisW-tracker457-branch
	test_ActionsTool.py 
Log Message:
Commit so I can work more at home.

=== CMF/CMFCore/tests/test_ActionsTool.py 1.2.14.1 => 1.2.14.2 ===
 from unittest import TestCase,TestSuite,makeSuite,main
-from Products.CMFCore.ActionsTool import *
-from Products.CMFDefault.URLTool import *
+from Products.CMFCore.ActionsTool import ActionsTool
+from Products.CMFCore.TypesTool import TypesTool
+from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFDefault.URLTool import URLTool
+from Products.CMFDefault.RegistrationTool import RegistrationTool
+from Products.CMFDefault.MembershipTool import MembershipTool
 import ZPublisher.HTTPRequest
 from Testing.makerequest import makerequest
 
@@ -9,7 +13,11 @@
 
     def setUp( self ):
         
-        root = self.root = makerequest(Zope.app())
+        get_transaction().begin()
+        self.connection = Zope.DB.open()
+        root = self.connection.root()[ 'Application' ]
+        root = self.root = makerequest(root)
+        
         root._setObject( 'portal_actions', ActionsTool() )
         root._setObject('foo', URLTool() )
         self.tool = root.portal_actions
@@ -18,6 +26,7 @@
 
     def tearDown(self):
         get_transaction().abort()
+        self.connection.close()
         
     def test_actionProviders(self):
         tool = self.tool
@@ -34,6 +43,32 @@
         tool.deleteActionProvider('foo')
         self.assertEqual(tool.listActionProviders(),
                           ('portal_actions',))
+
+    def test_listActionInformationActions(self):
+        """
+        Check that listFilteredActionsFor works for objects
+        that return ActionInformation objects
+        """
+        root = self.root
+        tool = self.tool
+        root._setObject('portal_registration', RegistrationTool())
+        root._setObject('portal_membership', MembershipTool())
+        root._setObject('portal_types', TypesTool())
+        self.tool.action_providers = ('portal_actions','portal_registration')
+        tool.listFilteredActionsFor(root.portal_registration)
+        
+    def test_listDictionaryActions(self):
+        """
+        Check that listFilteredActionsFor works for objects
+        that return dictionaries
+        """
+        root = self.root
+        tool = self.tool
+        root._setObject('donkey', PortalFolder('donkey'))
+        root._setObject('portal_membership', MembershipTool())
+        root._setObject('portal_types', TypesTool())
+        print tool.listFilteredActionsFor(root.donkey)
+
 
 def test_suite():
     return TestSuite((