[CMF-checkins] CVS: Products/CMFCore/tests - test_ActionInformation.py:1.17

Stefan H. Holek stefan at epy.co.at
Sat Jul 16 08:15:36 EDT 2005


Update of /cvs-repository/Products/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv12959/CMFCore/tests

Modified Files:
	test_ActionInformation.py 
Log Message:
CMFCore/ActionInformation.py: Permissions of action categories starting
with 'document' are now evaluated in the object context instead of the
portal context. This should probably be generalized some more.


=== Products/CMFCore/tests/test_ActionInformation.py 1.16 => 1.17 ===
--- Products/CMFCore/tests/test_ActionInformation.py:1.16	Sun Jun 26 07:10:09 2005
+++ Products/CMFCore/tests/test_ActionInformation.py	Sat Jul 16 08:15:36 2005
@@ -20,6 +20,7 @@
 import Zope2
 Zope2.startup()
 
+from OFS.Folder import manage_addFolder
 from Products.PythonScripts.PythonScript import manage_addPythonScript
 
 from Products.CMFCore.Expression import createExprContext
@@ -221,6 +222,73 @@
         self.assertEqual( ai['available'], WANTED['available'] )
         self.assertEqual( ai['allowed'], WANTED['allowed'] )
         self.assertEqual( ai, WANTED )
+
+    def test_category_object(self):
+        # Permissions for action category 'object*' should be
+        # evaluated in object context.
+        manage_addFolder(self.site, 'actions_dummy')
+        self.object = self.site.actions_dummy
+        self.object.manage_permission('View', [], acquire=0)
+
+        WANTED = {'allowed': False, 'category': 'object'}
+
+        action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
+        ec = createExprContext(self.site, self.site, self.object)
+        ai = self._makeOne(action, ec)
+
+        self.assertEqual( ai['category'], WANTED['category'] )
+        self.assertEqual( ai['allowed'], WANTED['allowed'] )
+
+    def test_category_folder(self):
+        # Permissions for action category 'folder*' should be
+        # evaluated in folder context.
+        manage_addFolder(self.site, 'actions_dummy')
+        self.folder = self.site.actions_dummy
+        self.folder.manage_permission('View', [], acquire=0)
+
+        WANTED = {'allowed': False, 'category': 'folder'}
+
+        action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
+        ec = createExprContext(self.folder, self.site, None)
+        ai = self._makeOne(action, ec)
+        ai['category'] = 'folder' # pfff
+
+        self.assertEqual( ai['category'], WANTED['category'] )
+        self.assertEqual( ai['allowed'], WANTED['allowed'] )
+
+    def test_category_workflow(self):
+        # Permissions for action category 'workflow*' should be
+        # evaluated in object context.
+        manage_addFolder(self.site, 'actions_dummy')
+        self.object = self.site.actions_dummy
+        self.object.manage_permission('View', [], acquire=0)
+
+        WANTED = {'allowed': False, 'category': 'workflow'}
+
+        action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
+        ec = createExprContext(self.site, self.site, self.object)
+        ai = self._makeOne(action, ec)
+        ai['category'] = 'workflow' # pfff
+
+        self.assertEqual( ai['category'], WANTED['category'] )
+        self.assertEqual( ai['allowed'], WANTED['allowed'] )
+
+    def test_category_document(self):
+        # Permissions for action category 'document*' should be
+        # evaluated in object context (not in portal context).
+        manage_addFolder(self.site, 'actions_dummy')
+        self.object = self.site.actions_dummy
+        self.object.manage_permission('View', [], acquire=0)
+
+        WANTED = {'allowed': False, 'category': 'document'}
+
+        action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
+        ec = createExprContext(self.site, self.site, self.object)
+        ai = self._makeOne(action, ec)
+        ai['category'] = 'document' # pfff
+
+        self.assertEqual( ai['category'], WANTED['category'] )
+        self.assertEqual( ai['allowed'], WANTED['allowed'] )
 
     def test_copy(self):
         action = {'name': 'foo', 'url': '', 'permissions': ('View',)}



More information about the CMF-checkins mailing list