Back to index

plone3  3.1.7
testActionIconsTool.py
Go to the documentation of this file.
00001 #
00002 # ActionIconsTool tests
00003 #
00004 
00005 from Products.CMFPlone.tests import PloneTestCase
00006 
00007 
00008 class TestActionIconsTool(PloneTestCase.PloneTestCase):
00009 
00010     def afterSetUp(self):
00011         self.actionicons = self.portal.portal_actionicons
00012         self._refreshSkinData()
00013         
00014     def testAddActionIcon(self):
00015         length = len(self.actionicons.listActionIcons())
00016         self.actionicons.addActionIcon('content_actions',
00017                                        'preview',
00018                                        'lock_icon.gif',
00019                                        title='preview')
00020         action_icons=self.actionicons.listActionIcons()
00021         preview=action_icons[-1]
00022         self.assertEqual(len(action_icons), length+1)
00023         self.assertEqual(preview._category, 'content_actions')
00024         self.assertEqual(preview._action_id, 'preview')
00025         self.assertEqual(preview._title, 'preview')
00026 
00027     def testRenderActionIcon(self):
00028         self.testAddActionIcon()
00029         icon=self.actionicons.renderActionIcon('content_actions',
00030                                                'preview')
00031         obj=self.portal.restrictedTraverse('lock_icon.gif')
00032         self.assertEqual(obj, icon)
00033 
00034     def testRenderDefaultActionIcon(self):
00035         icon=self.actionicons.renderActionIcon('content_actions',
00036                                                'doesnotexist',
00037                                                default='document_icon.gif')
00038         obj=self.portal.restrictedTraverse('document_icon.gif')
00039         self.assertEqual(obj, icon)
00040 
00041     def testRenderNoneActionIcon(self):
00042         icon=self.actionicons.renderActionIcon('content_actions',
00043                                                'doesnotexist',
00044                                                None)
00045         self.assertEqual(icon, None)
00046 
00047 
00048 def test_suite():
00049     from unittest import TestSuite, makeSuite
00050     suite = TestSuite()
00051     suite.addTest(makeSuite(TestActionIconsTool))
00052     return suite