[775] | 1 | import unittest |
---|
| 2 | |
---|
[799] | 3 | from zope.interface import Interface |
---|
[775] | 4 | from zope.interface.verify import verifyClass |
---|
[799] | 5 | from zope.component import getMultiAdapter, provideAdapter |
---|
[775] | 6 | |
---|
| 7 | from Products.CMFCore.utils import getToolByName |
---|
[798] | 8 | from Products.CMFCore.ActionInformation import Action, ActionCategory |
---|
[775] | 9 | |
---|
| 10 | from quintagroup.plonetabs.browser.interfaces import IPloneTabsControlPanel |
---|
| 11 | from quintagroup.plonetabs.browser.plonetabs import PloneTabsControlPanel as ptp |
---|
| 12 | from quintagroup.plonetabs.tests.base import PloneTabsTestCase |
---|
[798] | 13 | from quintagroup.plonetabs.tests.data import PORTAL_ACTIONS |
---|
[775] | 14 | |
---|
[798] | 15 | |
---|
| 16 | class TestControlPanelHelperMethods(PloneTabsTestCase): |
---|
| 17 | """Test here configlet helper methods""" |
---|
[775] | 18 | |
---|
| 19 | def afterSetUp(self): |
---|
[865] | 20 | super(TestControlPanelHelperMethods, self).afterSetUp() |
---|
[775] | 21 | self.loginAsPortalOwner() |
---|
[865] | 22 | panel = getMultiAdapter((self.portal, self.portal.REQUEST), |
---|
| 23 | name='plonetabs-controlpanel') |
---|
| 24 | # we need this to apply zope2 security (got from zope2 traverse method) |
---|
| 25 | self.panel = panel.__of__(self.portal) |
---|
[775] | 26 | self.tool = getToolByName(self.portal, 'portal_actions') |
---|
| 27 | |
---|
[798] | 28 | def test_redirect(self): |
---|
| 29 | response = self.portal.REQUEST.RESPONSE |
---|
| 30 | method = self.panel.redirect |
---|
| 31 | portal_url = getMultiAdapter((self.portal, self.portal.REQUEST), |
---|
| 32 | name=u"plone_portal_state").portal_url() |
---|
[865] | 33 | url = '%s/@@plonetabs-controlpanel' % portal_url |
---|
[798] | 34 | method() |
---|
| 35 | self.assertEquals(response.headers.get('location', ''), url, |
---|
| 36 | 'Redirect method is not working properly.') |
---|
| 37 | |
---|
| 38 | # check query string and anchor hash |
---|
| 39 | method('http://quintagroup.com', 'q=test', 'hash_code') |
---|
| 40 | self.assertEquals(response.headers.get('location', ''), |
---|
| 41 | 'http://quintagroup.com?q=test#hash_code', |
---|
| 42 | 'Redirect method is not working properly.') |
---|
| 43 | |
---|
| 44 | def test_fixExpression(self): |
---|
| 45 | method = self.panel.fixExpression |
---|
| 46 | self.assertEquals(method('/slash'), 'string:${portal_url}/slash') |
---|
| 47 | self.assertEquals(method('https://test.com'), 'string:https://test.com') |
---|
| 48 | self.assertEquals(method('python:True'), 'python:True') |
---|
| 49 | self.assertEquals(method('hello'), 'string:${object_url}/hello') |
---|
| 50 | |
---|
| 51 | def test_copyAction(self): |
---|
| 52 | data = PORTAL_ACTIONS[0][1]['children'][0][1] |
---|
| 53 | action = Action('act1', **data) |
---|
| 54 | info = self.panel.copyAction(action) |
---|
| 55 | self.assertEquals(len(info.keys()), 6) |
---|
| 56 | self.assertEquals(info['description'], 'The most important place') |
---|
| 57 | |
---|
| 58 | def test_validateActionFields(self): |
---|
| 59 | method = self.panel.validateActionFields |
---|
| 60 | good_data = PORTAL_ACTIONS[0][1]['children'][0][1].copy() |
---|
| 61 | good_data['id'] = 'new_one' |
---|
| 62 | errors = method('new_category', good_data) |
---|
| 63 | self.assertEquals(errors, {}, |
---|
| 64 | 'There should be no errors for valid data.') |
---|
| 65 | |
---|
| 66 | bad_data = {'id':'', |
---|
| 67 | 'title': ' ', |
---|
| 68 | 'available_expr': 'bad_type:test', |
---|
| 69 | 'url_expr': 'bad_type:test'} |
---|
[801] | 70 | |
---|
| 71 | # Revert PloneTestCase's optimization |
---|
| 72 | # because this breaks our test |
---|
| 73 | def __init__(self, text): |
---|
| 74 | self.text = text |
---|
| 75 | if text.strip(): |
---|
| 76 | self._v_compiled = getEngine().compile(text) |
---|
| 77 | from Products.CMFCore.Expression import Expression |
---|
| 78 | optimized__init__ = Expression.__init__ |
---|
| 79 | Expression.__init__ = __init__ |
---|
[798] | 80 | errors = method('new_category', bad_data) |
---|
[801] | 81 | # rollback our patch |
---|
| 82 | Expression.__init__ = optimized__init__ |
---|
| 83 | |
---|
[798] | 84 | self.assertEquals(len(errors.keys()), 4, |
---|
[801] | 85 | 'validateActionFields method is not working properly.') |
---|
[798] | 86 | |
---|
| 87 | def test_processErrors(self): |
---|
[799] | 88 | method = self.panel.processErrors |
---|
| 89 | errors = {'error':'error message'} |
---|
| 90 | self.assertEquals(method(errors), errors, |
---|
| 91 | 'processErrors method is not working properly.') |
---|
| 92 | self.assertEquals(method(errors, 'pre_', '_post'), |
---|
| 93 | {'pre_error_post': 'error message'}, |
---|
| 94 | 'processErrors method is not working properly.') |
---|
[798] | 95 | |
---|
| 96 | def test_parseEditForm(self): |
---|
[799] | 97 | method = self.panel.parseEditForm |
---|
| 98 | form = {'orig_id': 'id1', |
---|
| 99 | 'category': 'cat1', |
---|
| 100 | 'visible_id1': True, |
---|
| 101 | 'id_id1': 'id_new', |
---|
| 102 | 'title_id1': 'title1', |
---|
| 103 | 'url_expr_id1': 'expr1', |
---|
| 104 | 'available_expr_id1': 'expr2'} |
---|
| 105 | self.assertEquals(method(form), |
---|
| 106 | ('id1', 'cat1', {'id': 'id_new', |
---|
| 107 | 'title': 'title1', |
---|
| 108 | 'url_expr': 'expr1', |
---|
| 109 | 'available_expr': 'expr2', |
---|
| 110 | 'visible': True}), |
---|
| 111 | 'parseEditForm method is not working properly.') |
---|
| 112 | |
---|
| 113 | del form['orig_id'] |
---|
| 114 | self.failUnlessRaises(KeyError, method, form) |
---|
[798] | 115 | |
---|
| 116 | def test_parseAddForm(self): |
---|
[799] | 117 | method = self.panel.parseAddForm |
---|
| 118 | form = {'id': 'id1', |
---|
| 119 | 'category': 'cat1', |
---|
| 120 | 'visible': True, |
---|
| 121 | 'title': 'title1', |
---|
| 122 | 'url_expr': 'string:expr1', |
---|
| 123 | 'available_expr': 'expr2'} |
---|
| 124 | self.assertEquals(method(form), |
---|
| 125 | ('id1', 'cat1', {'id': 'id1', |
---|
| 126 | 'visible': True, |
---|
| 127 | 'title': 'title1', |
---|
| 128 | 'url_expr': 'string:expr1', |
---|
| 129 | 'available_expr': 'expr2'}), |
---|
| 130 | 'parseAddForm method is not working properly.') |
---|
| 131 | |
---|
| 132 | del form['id'] |
---|
| 133 | self.failUnlessRaises(KeyError, method, form) |
---|
[798] | 134 | |
---|
| 135 | def test_getActionCategory(self): |
---|
[799] | 136 | method = self.panel.getActionCategory |
---|
| 137 | self.purgeActions() |
---|
| 138 | self.failUnlessRaises(KeyError, method, 'portal_tabs') |
---|
| 139 | |
---|
| 140 | self.setupActions(self.tool) |
---|
| 141 | self.assertEquals(method('portal_tabs').id, 'portal_tabs', |
---|
| 142 | 'getActionCategory is not working properly.') |
---|
[798] | 143 | |
---|
| 144 | def test_getOrCreateCategory(self): |
---|
[799] | 145 | method = self.panel.getOrCreateCategory |
---|
| 146 | self.purgeActions() |
---|
| 147 | self.assertEquals(method('portal_tabs').id, 'portal_tabs', |
---|
| 148 | 'getOrCreateCategory is not working properly.') |
---|
[798] | 149 | |
---|
| 150 | def test_setSiteProperties(self): |
---|
[799] | 151 | self.panel.setSiteProperties(title='Test Title') |
---|
| 152 | sp = getToolByName(self.portal, 'portal_properties').site_properties |
---|
| 153 | self.assertEquals(sp.getProperty('title'), 'Test Title', |
---|
| 154 | 'setSiteProperties method is not working properly.') |
---|
[798] | 155 | |
---|
| 156 | def test_renderViewlet(self): |
---|
[799] | 157 | # register test viewlet and it's manager |
---|
| 158 | from zope.viewlet.interfaces import IViewlet, IViewletManager |
---|
| 159 | from zope.viewlet.viewlet import ViewletBase |
---|
| 160 | from zope.viewlet.manager import ViewletManagerBase |
---|
| 161 | from zope.publisher.interfaces.browser import IDefaultBrowserLayer |
---|
| 162 | from zope.publisher.interfaces.browser import IBrowserView |
---|
| 163 | class TestViewlet(ViewletBase): |
---|
| 164 | def __of__(self, obj): |
---|
| 165 | return self |
---|
| 166 | def render(self): |
---|
| 167 | return 'test viewlet' |
---|
| 168 | provideAdapter( |
---|
| 169 | TestViewlet, |
---|
| 170 | (Interface, IDefaultBrowserLayer, IBrowserView, IViewletManager), |
---|
| 171 | IViewlet, |
---|
| 172 | name=u'test_viewlet') |
---|
| 173 | provideAdapter( |
---|
| 174 | ViewletManagerBase, |
---|
| 175 | (Interface, IDefaultBrowserLayer, IBrowserView), |
---|
| 176 | IViewletManager, |
---|
| 177 | name=u'test_manager') |
---|
| 178 | |
---|
| 179 | self.assertEquals( |
---|
| 180 | self.panel.renderViewlet('test_manager', 'test_viewlet'), |
---|
| 181 | 'test viewlet', |
---|
| 182 | 'renderViewlet method is not workig properly') |
---|
[798] | 183 | |
---|
| 184 | def test_addAction(self): |
---|
[799] | 185 | self.purgeActions() |
---|
| 186 | self.panel.addAction('new_category', {'id':'id1', 'title':'Test'}) |
---|
| 187 | self.failUnless('id1' in self.tool.new_category.objectIds(), |
---|
| 188 | 'addAction method is not workig properly') |
---|
[798] | 189 | |
---|
| 190 | def test_updateAction(self): |
---|
[799] | 191 | method = self.panel.updateAction |
---|
| 192 | |
---|
| 193 | self.purgeActions() |
---|
| 194 | self.failUnlessRaises(KeyError, method, 'id1', 'cat1', {'id':'new'}) |
---|
| 195 | |
---|
| 196 | self.setupActions(self.tool) |
---|
| 197 | # we need to commit transaction because |
---|
| 198 | # we are going to rename just added action now |
---|
| 199 | import transaction |
---|
| 200 | transaction.savepoint() |
---|
| 201 | method('home', 'portal_tabs', {'id':'new_home'}) |
---|
| 202 | self.failUnless('new_home' in self.tool.portal_tabs.objectIds(), |
---|
| 203 | 'updateAction method is not workig properly') |
---|
[798] | 204 | |
---|
| 205 | def test_deleteAction(self): |
---|
[799] | 206 | self.purgeActions() |
---|
| 207 | self.setupActions(self.tool) |
---|
| 208 | self.panel.deleteAction('home', 'portal_tabs') |
---|
| 209 | self.failIf('home' in self.tool.portal_tabs.objectIds(), |
---|
| 210 | 'deleteAction method is not workig properly') |
---|
[798] | 211 | |
---|
| 212 | def test_moveAction(self): |
---|
[799] | 213 | self.purgeActions() |
---|
| 214 | self.setupActions(self.tool) |
---|
| 215 | pos = self.tool.portal_tabs.getObjectPosition |
---|
| 216 | self.assertEquals(pos('home'), 0, |
---|
| 217 | 'moveAction method is not workig properly') |
---|
| 218 | self.panel.moveAction('home', 'portal_tabs', -1) |
---|
| 219 | self.assertEquals(pos('home'), 1, |
---|
| 220 | 'moveAction method is not workig properly') |
---|
[798] | 221 | |
---|
| 222 | |
---|
| 223 | class TestControlPanelAPI(PloneTabsTestCase): |
---|
| 224 | """Test here interface methods of control panel class""" |
---|
| 225 | |
---|
| 226 | def afterSetUp(self): |
---|
[865] | 227 | super(TestControlPanelAPI, self).afterSetUp() |
---|
[798] | 228 | self.loginAsPortalOwner() |
---|
[865] | 229 | panel = getMultiAdapter((self.portal, self.portal.REQUEST), |
---|
| 230 | name='plonetabs-controlpanel') |
---|
| 231 | # we need this to apply zope2 security (got from zope2 traverse method) |
---|
| 232 | self.panel = panel.__of__(self.portal) |
---|
[798] | 233 | self.tool = getToolByName(self.portal, 'portal_actions') |
---|
| 234 | |
---|
[775] | 235 | def test_interface(self): |
---|
| 236 | self.failUnless(IPloneTabsControlPanel.implementedBy(ptp), |
---|
| 237 | 'PloneTabs control panel does not implement required interface.') |
---|
| 238 | self.failUnless(verifyClass(IPloneTabsControlPanel, ptp), |
---|
| 239 | 'PloneTabs control panel does not implement required interface.') |
---|
| 240 | |
---|
| 241 | def test_getPageTitle(self): |
---|
| 242 | self.assertEquals(self.panel.getPageTitle(), |
---|
| 243 | 'Portal Tabs Configuration', |
---|
| 244 | 'getPageTitle method is broken') |
---|
| 245 | self.assertEquals(self.panel.getPageTitle(category='notexists'), |
---|
| 246 | "Plone '%s' Configuration" % 'notexists', |
---|
| 247 | 'getPageTitle method is broken') |
---|
| 248 | |
---|
| 249 | def test_hasActions(self): |
---|
| 250 | method = self.panel.hasActions |
---|
| 251 | # purge any default portal actions |
---|
| 252 | self.purgeActions() |
---|
| 253 | self.failIf(method(), |
---|
| 254 | 'There should be no portal_tab actions in portal') |
---|
| 255 | |
---|
| 256 | # setup our own actions |
---|
| 257 | self.setupActions(self.tool) |
---|
| 258 | self.failUnless(method(), |
---|
| 259 | 'There should be portal_tab actions in portal') |
---|
| 260 | |
---|
| 261 | def test_getPortalActions(self): |
---|
| 262 | method = self.panel.getPortalActions |
---|
| 263 | # purge any default portal actions |
---|
| 264 | self.purgeActions() |
---|
| 265 | self.assertEquals(len(method()), 0, |
---|
| 266 | 'There should be no actions in portal_tabs category.') |
---|
| 267 | |
---|
| 268 | # setup our own actions |
---|
| 269 | self.setupActions(self.tool) |
---|
| 270 | self.assertEquals(len(method()), 2, |
---|
| 271 | 'There should be 2 actions in portal_tabs category.') |
---|
| 272 | |
---|
| 273 | # marginal arguments |
---|
| 274 | self.assertEquals(len(method('notexistent_category')), 0, |
---|
| 275 | 'There should be no actions for not existed category.') |
---|
| 276 | |
---|
| 277 | def test_isGeneratedTabs(self): |
---|
| 278 | method = self.panel.isGeneratedTabs |
---|
| 279 | # prepare value |
---|
| 280 | sp = getToolByName(self.portal, 'portal_properties').site_properties |
---|
| 281 | sp.manage_changeProperties(disable_folder_sections=True) |
---|
| 282 | self.failIf(method(), 'But folder sections are disabled...') |
---|
| 283 | |
---|
| 284 | def test_isNotFoldersGenerated(self): |
---|
| 285 | method = self.panel.isNotFoldersGenerated |
---|
| 286 | # prepare value |
---|
| 287 | sp = getToolByName(self.portal, 'portal_properties').site_properties |
---|
| 288 | sp.manage_changeProperties(disable_nonfolderish_sections=True) |
---|
| 289 | self.failIf(method(), 'But non folderish sections are disabled...') |
---|
| 290 | |
---|
| 291 | def test_getActionsList(self): |
---|
| 292 | method = self.panel.getActionsList |
---|
| 293 | # purge any default portal actions |
---|
| 294 | self.purgeActions() |
---|
| 295 | self.failIf('class="editform"' in method(), |
---|
| 296 | 'There should no be actions in actions list template.') |
---|
| 297 | self.setupActions(self.tool) |
---|
| 298 | self.failUnless('class="editform"' in method(), |
---|
| 299 | 'There are no actions in actions list template.') |
---|
| 300 | |
---|
| 301 | def test_getAutoGenereatedSection(self): |
---|
| 302 | method = self.panel.getAutoGenereatedSection |
---|
| 303 | self.failIf('<form' in method('user'), |
---|
| 304 | 'There should be no form in autogenerated tabs template ' |
---|
| 305 | 'for category other than portal_tabs.') |
---|
| 306 | self.failUnless('<form' in method('portal_tabs'), |
---|
| 307 | 'There should be form in autogenerated tabs template ' |
---|
| 308 | 'for portal_tabs category.') |
---|
| 309 | |
---|
| 310 | def test_getGeneratedTabs(self): |
---|
| 311 | self.panel.getGeneratedTabs() |
---|
| 312 | # check expiration header set by generated tabs template |
---|
| 313 | self.assertEquals( |
---|
| 314 | self.portal.REQUEST.RESPONSE.headers.get('expires', ''), |
---|
| 315 | 'Mon, 26 Jul 1996 05:00:00 GMT', |
---|
| 316 | 'Expiration header is not set properly.') |
---|
| 317 | |
---|
| 318 | def test_getRootTabs(self): |
---|
| 319 | method = self.panel.getRootTabs |
---|
| 320 | # make sure we don't depend on external settings |
---|
| 321 | self.purgeContent() |
---|
| 322 | self.assertEquals(len(method()), 0, |
---|
| 323 | 'There should be no root elements for navigation.') |
---|
| 324 | |
---|
| 325 | # now add some testing content |
---|
| 326 | self.setupContent(self.portal) |
---|
| 327 | self.assertEquals(len(method()), 2, |
---|
| 328 | 'There should be 2 elements in portal root for navigation.') |
---|
| 329 | |
---|
| 330 | # now switch off autogeneration |
---|
| 331 | sp = getToolByName(self.portal, 'portal_properties').site_properties |
---|
| 332 | sp.manage_changeProperties(disable_folder_sections=True) |
---|
| 333 | self.assertEquals(len(method()), 0, |
---|
| 334 | 'There should be no root elements for navigation when ' |
---|
| 335 | 'tabs autogeneration is switched off.') |
---|
| 336 | |
---|
| 337 | def test_getCategories(self): |
---|
| 338 | method = self.panel.getCategories |
---|
| 339 | # purge any default portal actions |
---|
| 340 | self.purgeActions() |
---|
| 341 | self.assertEquals(len(method()), 0, |
---|
| 342 | 'There should be no categories in portal_actions tool.') |
---|
| 343 | |
---|
| 344 | # now setup actions |
---|
| 345 | self.setupActions(self.tool) |
---|
| 346 | self.assertEquals(method(), ['portal_tabs', 'new_category'], |
---|
| 347 | 'There should be exactly 2 categories in portal_actions tool.') |
---|
| 348 | |
---|
| 349 | def test_portal_tabs(self): |
---|
| 350 | method = self.panel.portal_tabs |
---|
| 351 | self.purgeContent() |
---|
| 352 | self.purgeActions() |
---|
| 353 | self.assertEquals(len(method()), 0, |
---|
| 354 | 'There should be no portal tabs.') |
---|
| 355 | |
---|
[798] | 356 | # cleanup memoize cache |
---|
| 357 | # cause actions method of portal context state is caching it's |
---|
| 358 | # results in request and we have the same request for every call |
---|
| 359 | self.purgeCache(self.portal.REQUEST) |
---|
| 360 | |
---|
[775] | 361 | # add actions |
---|
| 362 | self.setupActions(self.tool) |
---|
| 363 | self.assertEquals(len(method()), 2, |
---|
| 364 | 'There should be 2 portal tabs.') |
---|
| 365 | |
---|
| 366 | # add content |
---|
| 367 | self.setupContent(self.portal) |
---|
| 368 | self.assertEquals(len(method()), 4, |
---|
| 369 | 'There should be 4 portal tabs.') |
---|
| 370 | |
---|
| 371 | def test_selected_portal_tab(self): |
---|
[798] | 372 | self.assertEquals(self.panel.selected_portal_tab(), 'index_html', |
---|
| 373 | 'index_html is not selected tab while being on configlet.') |
---|
[775] | 374 | |
---|
| 375 | def test_test(self): |
---|
[798] | 376 | self.assertEquals(self.panel.test(True, 'true', 'false'), 'true', |
---|
[801] | 377 | 'Test function does not work properly.') |
---|
[775] | 378 | |
---|
| 379 | |
---|
[801] | 380 | class TestControlPanelManageMethods(PloneTabsTestCase): |
---|
| 381 | """Test here management methods of control panel class""" |
---|
| 382 | |
---|
| 383 | def afterSetUp(self): |
---|
[865] | 384 | super(TestControlPanelManageMethods, self).afterSetUp() |
---|
[801] | 385 | self.loginAsPortalOwner() |
---|
[865] | 386 | panel = getMultiAdapter((self.portal, self.portal.REQUEST), |
---|
| 387 | name='plonetabs-controlpanel') |
---|
| 388 | # we need this to apply zope2 security (got from zope2 traverse method) |
---|
| 389 | self.panel = panel.__of__(self.portal) |
---|
[801] | 390 | self.tool = getToolByName(self.portal, 'portal_actions') |
---|
| 391 | |
---|
| 392 | # purge standard set of actions and set our own testing ones |
---|
| 393 | self.purgeActions() |
---|
| 394 | self.setupActions(self.tool) |
---|
| 395 | |
---|
| 396 | def test_manage_setAutogeneration(self): |
---|
| 397 | self.setupContent(self.portal) |
---|
| 398 | form = {'generated_tabs': '1', |
---|
| 399 | 'nonfolderish_tabs': '0', |
---|
| 400 | 'folder1': '0'} |
---|
| 401 | self.panel.manage_setAutogeneration(form, {}) |
---|
| 402 | self.failUnless(self.portal.folder1.exclude_from_nav()) |
---|
| 403 | sp = getToolByName(self.portal, 'portal_properties').site_properties |
---|
| 404 | self.failIf(sp.disable_folder_sections) |
---|
| 405 | self.failUnless(sp.disable_nonfolderish_sections) |
---|
| 406 | |
---|
| 407 | def test_manage_addAction(self): |
---|
| 408 | self.purgeActions() |
---|
| 409 | form = {'id': 'id1', |
---|
| 410 | 'category': 'cat1', |
---|
| 411 | 'visible': True, |
---|
| 412 | 'title': 'title1', |
---|
| 413 | 'url_expr': 'string:expr1', |
---|
| 414 | 'available_expr': 'expr2'} |
---|
| 415 | postback = self.panel.manage_addAction(form, {}) |
---|
| 416 | self.failUnless('id1' in self.tool.cat1.objectIds()) |
---|
| 417 | self.failIf(postback, |
---|
| 418 | 'There should be redirect after successfull adding.') |
---|
| 419 | |
---|
| 420 | def test_manage_editAction(self): |
---|
| 421 | method = self.panel.manage_editAction |
---|
| 422 | self.purgeActions() |
---|
| 423 | self.setupActions(self.tool) |
---|
| 424 | form = {'orig_id': 'home', |
---|
| 425 | 'category': 'portal_tabs', |
---|
| 426 | 'visible_home': True, |
---|
| 427 | 'id_home': 'id_new', |
---|
| 428 | 'title_home': 'title1', |
---|
| 429 | 'url_expr_home': 'expr1', |
---|
| 430 | 'available_expr_home': 'expr2'} |
---|
| 431 | import transaction |
---|
| 432 | transaction.savepoint() |
---|
| 433 | |
---|
| 434 | postback = method(form, {}) |
---|
| 435 | self.failUnless('id_new' in self.tool.portal_tabs.objectIds()) |
---|
| 436 | self.failIf(postback, |
---|
| 437 | 'There should be redirect after successfull edition.') |
---|
| 438 | |
---|
| 439 | form['category'] = 'non_existent' |
---|
| 440 | self.failUnlessRaises(KeyError, method, form, {}) |
---|
| 441 | |
---|
| 442 | def test_manage_deleteAction(self): |
---|
| 443 | self.purgeActions() |
---|
| 444 | self.setupActions(self.tool) |
---|
| 445 | form = {'orig_id': 'home', |
---|
| 446 | 'category': 'portal_tabs', |
---|
| 447 | 'visible_home': True, |
---|
| 448 | 'id_home': 'id_new', |
---|
| 449 | 'title_home': 'title1', |
---|
| 450 | 'url_expr_home': 'expr1', |
---|
| 451 | 'available_expr_home': 'expr2'} |
---|
| 452 | self.panel.manage_deleteAction(form, {}) |
---|
| 453 | self.failIf('home' in self.tool.portal_tabs.objectIds()) |
---|
| 454 | |
---|
| 455 | def test_manage_moveUpAction(self): |
---|
| 456 | self.purgeActions() |
---|
| 457 | self.setupActions(self.tool) |
---|
| 458 | form = {'orig_id': 'quintagroup', |
---|
| 459 | 'category': 'portal_tabs', |
---|
| 460 | 'visible_quintagroup': True, |
---|
| 461 | 'id_quintagroup': 'quintagroup', |
---|
| 462 | 'title_quintagroup': 'title1', |
---|
| 463 | 'url_expr_quintagroup': 'expr1', |
---|
| 464 | 'available_expr_quintagroup': 'expr2'} |
---|
| 465 | self.panel.manage_moveUpAction(form, {}) |
---|
| 466 | self.assertEquals( |
---|
| 467 | self.tool.portal_tabs.getObjectPosition('quintagroup'), 0) |
---|
| 468 | |
---|
| 469 | def test_manage_moveDownAction(self): |
---|
| 470 | self.purgeActions() |
---|
| 471 | self.setupActions(self.tool) |
---|
| 472 | form = {'orig_id': 'home', |
---|
| 473 | 'category': 'portal_tabs', |
---|
| 474 | 'visible_home': True, |
---|
| 475 | 'id_home': 'home', |
---|
| 476 | 'title_home': 'title1', |
---|
| 477 | 'url_expr_home': 'expr1', |
---|
| 478 | 'available_expr_home': 'expr2'} |
---|
| 479 | self.panel.manage_moveDownAction(form, {}) |
---|
| 480 | self.assertEquals(self.tool.portal_tabs.getObjectPosition('home'), 1) |
---|
| 481 | |
---|
| 482 | |
---|
[775] | 483 | def test_suite(): |
---|
| 484 | suite = unittest.TestSuite() |
---|
[798] | 485 | suite.addTest(unittest.makeSuite(TestControlPanelHelperMethods)) |
---|
[775] | 486 | suite.addTest(unittest.makeSuite(TestControlPanelAPI)) |
---|
[801] | 487 | suite.addTest(unittest.makeSuite(TestControlPanelManageMethods)) |
---|
[865] | 488 | |
---|
| 489 | # these tests are implemented as Selenium KSS Tests |
---|
| 490 | # using kss.demo package, and KSS plugins are tested by means of |
---|
| 491 | # ecmaunit.js |
---|
[775] | 492 | #suite.addTest(unittest.makeSuite(TestControlPanelKSSMethods)) |
---|
| 493 | return suite |
---|