Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
CMFActionIcons.tests.test_ActionIconsTool.ActionIconToolTests Class Reference

List of all members.

Public Member Functions

def test_interfaces
def test_empty
def test_addActionIcon
def test_addActionIcon_duplicate
def test_addActionIcon_multiple
def test_updateActionIcon
def test_updateActionIcon_emptyiconexpr
def test_updateActionIcon_nonesuch
def test_removeActionIcon
def test_removeActionIcon_nonesuch
def test_removeActionIcon_noIconURL
def test_updateActionDicts

Private Member Functions

def _makeOne

Detailed Description

Definition at line 24 of file test_ActionIconsTool.py.


Member Function Documentation

Definition at line 26 of file test_ActionIconsTool.py.

00026 
00027     def _makeOne( self, *args, **kw ):
00028 
00029         from Products.CMFActionIcons.ActionIconsTool import ActionIconsTool
00030 
00031         return ActionIconsTool( *args, **kw )

Definition at line 48 of file test_ActionIconsTool.py.

00048 
00049     def test_addActionIcon( self ):
00050 
00051         tool = self._makeOne()
00052 
00053         tool.addActionIcon( 'foo', 'bar', 'qux' )
00054 
00055         icons = tool.listActionIcons()
00056         self.assertEqual( len( icons ), 1 )
00057 
00058         icon = icons[0]
00059         self.assertEqual( icon.getCategory(), 'foo' )
00060         self.assertEqual( icon.getActionId(), 'bar' )
00061         self.assertEqual( icon.getExpression(), 'qux' )
00062         self.assertEqual( icon.getIconURL(), 'qux' )
00063 
00064         self.assertRaises( KeyError, tool.getActionIcon, 'foo', 'baz' )
00065         self.assertEqual( tool.getActionIcon( 'foo', 'bar' ), 'qux' )
00066         self.assertEqual( tool.queryActionIcon( 'foo', 'bar' ), 'qux' )
00067         self.assertEqual( tool.queryActionIcon( 'foo', 'bar', 'baz' ), 'qux' )

Here is the call graph for this function:

Definition at line 68 of file test_ActionIconsTool.py.

00068 
00069     def test_addActionIcon_duplicate( self ):
00070 
00071         tool = self._makeOne()
00072 
00073         tool.addActionIcon( 'foo', 'bar', 'qux' )
00074         self.assertRaises( KeyError, tool.addActionIcon, 'foo', 'bar', 'qux' )

Here is the call graph for this function:

Definition at line 75 of file test_ActionIconsTool.py.

00075 
00076     def test_addActionIcon_multiple( self ):
00077 
00078         tool = self._makeOne()
00079 
00080         tool.addActionIcon( 'foo', 'bar', 'qux' )
00081         tool.addActionIcon( 'foo', 'baz', 'spam' )
00082         tool.addActionIcon( 'abc', 'def', 'ghi' )
00083 
00084         icons = tool.listActionIcons()
00085         self.assertEqual( len( icons ), 3 )
00086 
00087         icon = icons[0]
00088         self.assertEqual( icon.getCategory(), 'foo' )
00089         self.assertEqual( icon.getActionId(), 'bar' )
00090         self.assertEqual( icon.getExpression(), 'qux' )
00091         self.assertEqual( icon.getIconURL(), 'qux' )
00092 
00093         icon = icons[1]
00094         self.assertEqual( icon.getCategory(), 'foo' )
00095         self.assertEqual( icon.getActionId(), 'baz' )
00096         self.assertEqual( icon.getExpression(), 'spam' )
00097         self.assertEqual( icon.getIconURL(), 'spam' )
00098 
00099         icon = icons[2]
00100         self.assertEqual( icon.getCategory(), 'abc' )
00101         self.assertEqual( icon.getActionId(), 'def' )
00102         self.assertEqual( icon.getExpression(), 'ghi' )
00103         self.assertEqual( icon.getIconURL(), 'ghi' )

Here is the call graph for this function:

Definition at line 38 of file test_ActionIconsTool.py.

00038 
00039     def test_empty( self ):
00040 
00041         tool = self._makeOne()
00042 
00043         self.assertEqual( len( tool.listActionIcons() ), 0 )
00044         self.assertRaises( KeyError, tool.getActionIcon, 'foo', 'bar' )
00045         self.assertEqual( tool.queryActionIcon( 'foo', 'bar' ), None )
00046         self.assertEqual( tool.queryActionIcon( 'foo', 'bar', 'baz' ), 'baz' )
00047         self.assertRaises( KeyError, tool.removeActionIcon, 'foo', 'bar' )

Here is the call graph for this function:

Definition at line 32 of file test_ActionIconsTool.py.

00032 
00033     def test_interfaces(self):
00034         from Products.CMFActionIcons.ActionIconsTool import ActionIconsTool
00035         from Products.CMFActionIcons.interfaces import IActionIconsTool
00036 
00037         verifyClass(IActionIconsTool, ActionIconsTool)

Definition at line 139 of file test_ActionIconsTool.py.

00139 
00140     def test_removeActionIcon( self ):
00141 
00142         tool = self._makeOne()
00143 
00144         tool.addActionIcon( 'foo', 'bar', 'qux' )
00145         tool.addActionIcon( 'foo', 'baz', 'spam' )
00146         tool.addActionIcon( 'abc', 'def', 'ghi' )
00147 
00148         tool.removeActionIcon( 'foo', 'baz' )
00149 
00150         icons = tool.listActionIcons()
00151         self.assertEqual( len( icons ), 2 )
00152 
00153         icon = icons[0]
00154         self.assertEqual( icon.getCategory(), 'foo' )
00155         self.assertEqual( icon.getActionId(), 'bar' )
00156         self.assertEqual( icon.getExpression(), 'qux' )
00157         self.assertEqual( icon.getIconURL(), 'qux' )
00158 
00159         icon = icons[1]
00160         self.assertEqual( icon.getCategory(), 'abc' )
00161         self.assertEqual( icon.getActionId(), 'def' )
00162         self.assertEqual( icon.getExpression(), 'ghi' )
00163         self.assertEqual( icon.getIconURL(), 'ghi' )
00164 
00165         self.assertEqual( tool.getActionIcon( 'foo', 'bar' ), 'qux' )
00166         self.assertRaises( KeyError, tool.getActionIcon, 'foo', 'baz' )
00167         self.assertEqual( tool.getActionIcon( 'abc', 'def' ), 'ghi' )

Here is the call graph for this function:

Definition at line 178 of file test_ActionIconsTool.py.

00178 
00179     def test_removeActionIcon_noIconURL( self ):
00180         # Regression test, issue #333
00181         tool = self._makeOne()
00182         tool.addActionIcon( 'foo', 'bar', '' )
00183 
00184         tool.removeActionIcon( 'foo', 'bar' )
00185         self.assertEqual(len(tool.listActionIcons()), 0)

Here is the call graph for this function:

Definition at line 168 of file test_ActionIconsTool.py.

00168 
00169     def test_removeActionIcon_nonesuch( self ):
00170 
00171         tool = self._makeOne()
00172 
00173         tool.addActionIcon( 'foo', 'bar', 'qux' )
00174         tool.addActionIcon( 'foo', 'baz', 'spam' )
00175         tool.addActionIcon( 'abc', 'def', 'ghi' )
00176 
00177         self.assertRaises( KeyError, tool.removeActionIcon, 'jkl', 'mno' )

Here is the call graph for this function:

Definition at line 186 of file test_ActionIconsTool.py.

00186 
00187     def test_updateActionDicts( self ):
00188 
00189         tool = self._makeOne()
00190 
00191         tool.addActionIcon( 'foo', 'bar', 'qux', 'FooBar' )
00192         tool.addActionIcon( 'foo', 'baz', 'spam', 'FooBaz', 1 )
00193         tool.addActionIcon( 'abc', 'def', 'ghi' )
00194 
00195         sod = { 'foo' : ( { 'id' : 'bar' }
00196                         , { 'id' : 'baz', 'icon' : 'qwerty' }
00197                         , { 'id' : 'bam' }
00198                         )
00199               , 'abc' : ( { 'id' : 'def', 'title' : 'DEF' }
00200                         ,
00201                         )
00202               }
00203 
00204         sod2 = tool.updateActionDicts( sod )
00205 
00206         self.assertEqual( len( sod2 ), len( sod ) )
00207 
00208         self.assertEqual( len( sod2['foo'] ), len( sod['foo'] ) )
00209         self.assertEqual( sod2['foo'][0]['icon'], 'qux' )
00210         self.assertEqual( sod2['foo'][0]['title'], 'FooBar' )
00211         self.assertEqual( sod2['foo'][0]['priority'], 0 )
00212 
00213         self.failIf( sod2['foo'][1].has_key( 'icon' ) ) # sorted higher!
00214 
00215         self.assertEqual( sod2['foo'][2]['icon'], 'spam' )
00216         self.assertEqual( sod2['foo'][2]['title'], 'FooBaz' )
00217         self.assertEqual( sod2['foo'][2]['priority'], 1 )
00218 
00219         self.assertEqual( len( sod2['abc'] ), len( sod['abc'] ) )
00220         self.assertEqual( sod2['abc'][0]['icon'], 'ghi' )
00221         self.assertEqual( sod2['abc'][0]['title'], 'DEF' )
00222 
00223         sod3 = tool( sod )
00224         self.assertEqual( sod2, sod3 )
00225 

Here is the call graph for this function:

Definition at line 104 of file test_ActionIconsTool.py.

00104 
00105     def test_updateActionIcon( self ):
00106 
00107         tool = self._makeOne()
00108 
00109         tool.addActionIcon( 'foo', 'bar', 'qux' )
00110 
00111         self.assertEqual( tool.getActionIcon( 'foo', 'bar' ), 'qux' )
00112         self.assertEqual( tool.queryActionIcon( 'foo', 'bar' ), 'qux' )
00113         self.assertEqual( tool.queryActionIcon( 'foo', 'bar', 'baz' ), 'qux' )
00114 
00115         tool.updateActionIcon( 'foo', 'bar', 'bam' )
00116 
00117         self.assertEqual( tool.getActionIcon( 'foo', 'bar' ), 'bam' )
00118         self.assertEqual( tool.queryActionIcon( 'foo', 'bar' ), 'bam' )
00119         self.assertEqual( tool.queryActionIcon( 'foo', 'bar', 'baz' ), 'bam' )

Here is the call graph for this function:

Definition at line 120 of file test_ActionIconsTool.py.

00120 
00121     def test_updateActionIcon_emptyiconexpr( self ):
00122 
00123         # CMF Collector # 239
00124 
00125         tool = self._makeOne()
00126         tool.addActionIcon( 'foo', 'bar', 'qux' )
00127         tool.updateActionIcon( 'foo', 'bar', '' )
00128         tool.updateActionIcon( 'foo', 'bar', 'bam' )
00129 
00130         self.assertEqual( tool.getActionIcon( 'foo', 'bar' ), 'bam' )
00131         self.assertEqual( tool.queryActionIcon( 'foo', 'bar' ), 'bam' )
00132         self.assertEqual( tool.queryActionIcon( 'foo', 'bar', 'baz' ), 'bam' )

Here is the call graph for this function:

Definition at line 133 of file test_ActionIconsTool.py.

00133 
00134     def test_updateActionIcon_nonesuch( self ):
00135 
00136         tool = self._makeOne()
00137         self.assertRaises( KeyError
00138                          , tool.updateActionIcon, 'foo', 'baz', 'qux' )

Here is the call graph for this function:


The documentation for this class was generated from the following file: