[z3-checkins] r8251 - in z3/CMFonFive/branch/regebro-action_menus:
. tests/products tests/products/CMFonFiveTest/tests
regebro at codespeak.net
regebro at codespeak.net
Thu Jan 13 12:25:50 MET 2005
Author: regebro
Date: Thu Jan 13 12:25:50 2005
New Revision: 8251
Added:
z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/
z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/__init__.py (contents, props changed)
z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/test_actionstool.py (contents, props changed)
z3/CMFonFive/branch/regebro-action_menus/tests/products/README.txt (contents, props changed)
z3/CMFonFive/branch/regebro-action_menus/tool.gif (contents, props changed)
Modified:
z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py
Log:
Adding more tests
Modified: z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py
==============================================================================
--- z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py (original)
+++ z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py Thu Jan 13 12:25:50 2005
@@ -42,9 +42,13 @@
menu = globalBrowserMenuService.getMenu(mid, object, self.REQUEST)
for entry in menu:
act = {}
+ # Set the action category to the menu name (not unicode!)
act['category'] = str(mid)
act['url'] = str(entry['action'])
- act['name'] = 'action_%s%s' % (object.getId(), act['url'])
+ # The action needs a unique name, so I'll build one
+ # from the object_id and the action url. That is sure
+ # to be unique.
+ act['name'] = 'action_%s_%s' % (object.getId(), act['url'])
act['title'] = str(entry['title'])
actions.append(act)
return actions or ()
Added: z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/__init__.py
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/__init__.py Thu Jan 13 12:25:50 2005
@@ -0,0 +1,4 @@
+""" Unit tests for CMFonFive.
+
+$Id$
+"""
Added: z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/test_actionstool.py
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/products/CMFonFiveTest/tests/test_actionstool.py Thu Jan 13 12:25:50 2005
@@ -0,0 +1,46 @@
+""" Unit tests for mapped interfaces.
+
+$Id$
+"""
+
+import unittest
+from Testing import ZopeTestCase
+from Testing.ZopeTestCase.functional import Functional
+from Products.CMFCore.utils import getToolByName
+
+# we need to install test products *before* Five as Five
+# looks up zcml files in the products it can find.
+ZopeTestCase.installProduct('CMFonFiveTest')
+ZopeTestCase.installProduct('CMFonFive')
+ZopeTestCase.installProduct('Five')
+
+class ActionsToolTests(ZopeTestCase.ZopeTestCase):
+
+ def afterSetUp(self):
+ self.folder.manage_addProduct['CMFonFive'].manage_addTool(
+ 'Five Actions Tool')
+
+ def test_ActionsToolDocument(self):
+ tool = getToolByName(self.folder, 'portal_fiveactions')
+ # The action created for the content should appear in the list
+ # of actions for such content
+ self.folder.manage_addProduct['CMFonFiveTest'].manage_addCMFContent(
+ 'content', 'Content Title')
+ actions = tool.listActions(object=self.folder.content)
+ action_names = [action['name'] for action in actions]
+ self.failUnless('action_content_seagull.html' in action_names,
+ 'Expected menu item was not found in action list')
+ # But not for anything else:
+ self.failUnlessEqual(list(tool.listActions(object=self.folder)), [])
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(ActionsToolTests))
+ return suite
+
+
+
+
+if __name__ == '__main__':
+ unittest.main()
Added: z3/CMFonFive/branch/regebro-action_menus/tests/products/README.txt
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/products/README.txt Thu Jan 13 12:25:50 2005
@@ -0,0 +1,17 @@
+This directory contains a product CMFonFiveTest, which is used to
+do testing of CMFonFive. Mainly, it tests that the zcml statements
+work, by having a small product that uses the zcml statements.
+
+Most other things can be tested in the main unit tests of CMFonFive.
+
+To use these tests, move or link) the CMFonFiveTest directory to
+your Products directory:
+
+ cd <zope_dir>/Products
+ ln -s CMFonFive/tests/products/CMFonFiveTest .
+
+Then run the unit tests as normal
+
+ cd <zope_dir>
+ bin/zopectl test --dir Products/CMFonFiveTest
+
Added: z3/CMFonFive/branch/regebro-action_menus/tool.gif
==============================================================================
Binary file. No diff available.
More information about the z3-checkins
mailing list