Changeset 3608 in products for quintagroup.plonetabs/trunk
- Timestamp:
- Oct 25, 2012 10:46:03 AM (12 years ago)
- Location:
- quintagroup.plonetabs/trunk/quintagroup/plonetabs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py
r3598 r3608 223 223 self.moveAction(id, cat_name, steps=1) 224 224 IStatusMessage(self.request).addStatusMessage( 225 _(u"'${id}' action moved up.", mapping={'id': id}), type="info") 225 _(u"'${id}' action moved up.", mapping={'id': id}), 226 type="info") 226 227 self.redirect(search="category=%s" % cat_name) 227 228 return False … … 687 688 self.kss_toggleCollapsible( 688 689 ksscore.getCssSelector('form[name=addaction_form] ' 689 '.headerAdvanced'), collapse='false') 690 '.headerAdvanced'), 691 collapse='false') 690 692 691 693 message = _(u"Please correct the indicated errors.") -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_controlpanel.py
r3437 r3608 11 11 from quintagroup.plonetabs.browser.interfaces import IPloneTabsControlPanel 12 12 from quintagroup.plonetabs.browser.plonetabs \ 13 13 import PloneTabsControlPanel as ptp 14 14 from quintagroup.plonetabs.tests.base import PloneTabsTestCase 15 15 from quintagroup.plonetabs.tests.data import PORTAL_ACTIONS … … 22 22 self.loginAsPortalOwner() 23 23 panel = getMultiAdapter((self.portal, self.portal.REQUEST), 24 name='plonetabs-controlpanel')24 name='plonetabs-controlpanel') 25 25 # we need this to apply zope2 security (got from zope2 traverse method) 26 26 self.panel = panel.__of__(self.portal) … … 31 31 method = self.panel.redirect 32 32 portal_url = getMultiAdapter((self.portal, self.portal.REQUEST), 33 33 name=u"plone_portal_state").portal_url() 34 34 url = '%s/@@plonetabs-controlpanel' % portal_url 35 35 method() 36 36 self.assertEquals(response.headers.get('location', ''), url, 37 'Redirect method is not working properly.')37 'Redirect method is not working properly.') 38 38 39 39 # check query string and anchor hash 40 40 method('http://quintagroup.com', 'q=test', 'hash_code') 41 41 self.assertEquals(response.headers.get('location', ''), 42 'http://quintagroup.com?q=test#hash_code',43 'Redirect method is not working properly.')42 'http://quintagroup.com?q=test#hash_code', 43 'Redirect method is not working properly.') 44 44 45 45 def test_fixExpression(self): … … 47 47 self.assertEquals(method('/slash'), 'string:${portal_url}/slash') 48 48 self.assertEquals(method('https://test.com'), 49 49 'string:https://test.com') 50 50 self.assertEquals(method('python:True'), 'python:True') 51 51 self.assertEquals(method('hello'), 'string:${object_url}/hello') … … 64 64 errors = method('new_category', good_data) 65 65 self.assertEquals(errors, {}, 66 'There should be no errors for valid data.')66 'There should be no errors for valid data.') 67 67 68 68 bad_data = {'id': '', … … 88 88 89 89 self.assertEquals(len(errors.keys()), 4, 90 'validateActionFields method is not working properly.') 90 'validateActionFields method is not working ' 91 'properly.') 91 92 #### pyflakes.scripts.pyflakes ends. 92 93 … … 95 96 errors = {'error': 'error message'} 96 97 self.assertEquals(method(errors), errors, 97 'processErrors method is not working properly.')98 'processErrors method is not working properly.') 98 99 self.assertEquals(method(errors, 'pre_', '_post'), 99 {'pre_error_post': 'error message'},100 'processErrors method is not working properly.')100 {'pre_error_post': 'error message'}, 101 'processErrors method is not working properly.') 101 102 102 103 def test_parseEditForm(self): … … 110 111 'available_expr_id1': 'expr2'} 111 112 self.assertEquals(method(form), 112 ('id1', 'cat1', {'id': 'id_new',113 'title': 'title1',114 'url_expr': 'expr1',115 'available_expr': 'expr2',116 'visible': True}),117 'parseEditForm method is not working properly.')113 ('id1', 'cat1', {'id': 'id_new', 114 'title': 'title1', 115 'url_expr': 'expr1', 116 'available_expr': 'expr2', 117 'visible': True}), 118 'parseEditForm method is not working properly.') 118 119 119 120 del form['orig_id'] … … 129 130 'available_expr': 'expr2'} 130 131 self.assertEquals(method(form), 131 ('id1', 'cat1', {'id': 'id1',132 'visible': True,133 'title': 'title1',134 'url_expr': 'string:expr1',135 'available_expr': 'expr2'}),136 'parseAddForm method is not working properly.')132 ('id1', 'cat1', {'id': 'id1', 133 'visible': True, 134 'title': 'title1', 135 'url_expr': 'string:expr1', 136 'available_expr': 'expr2'}), 137 'parseAddForm method is not working properly.') 137 138 138 139 del form['id'] … … 146 147 self.setupActions(self.tool) 147 148 self.assertEquals(method('portal_tabs').id, 'portal_tabs', 148 'getActionCategory is not working properly.')149 'getActionCategory is not working properly.') 149 150 150 151 def test_getOrCreateCategory(self): … … 152 153 self.purgeActions() 153 154 self.assertEquals(method('portal_tabs').id, 'portal_tabs', 154 'getOrCreateCategory is not working properly.')155 'getOrCreateCategory is not working properly.') 155 156 156 157 def test_setSiteProperties(self): … … 158 159 sp = getToolByName(self.portal, 'portal_properties').site_properties 159 160 self.assertEquals(sp.getProperty('title'), 'Test Title', 160 'setSiteProperties method is not working properly.')161 'setSiteProperties method is not working properly.') 161 162 162 163 def test_renderViewlet(self): … … 195 196 self.panel.addAction('new_category', {'id': 'id1', 'title': 'Test'}) 196 197 self.failUnless('id1' in self.tool.new_category.objectIds(), 197 'addAction method is not workig properly')198 'addAction method is not workig properly') 198 199 199 200 def test_updateAction(self): … … 210 211 method('home', 'portal_tabs', {'id': 'new_home'}) 211 212 self.failUnless('new_home' in self.tool.portal_tabs.objectIds(), 212 'updateAction method is not workig properly')213 'updateAction method is not workig properly') 213 214 214 215 def test_deleteAction(self): … … 217 218 self.panel.deleteAction('home', 'portal_tabs') 218 219 self.failIf('home' in self.tool.portal_tabs.objectIds(), 219 'deleteAction method is not workig properly')220 'deleteAction method is not workig properly') 220 221 221 222 def test_moveAction(self): … … 224 225 pos = self.tool.portal_tabs.getObjectPosition 225 226 self.assertEquals(pos('home'), 0, 226 'moveAction method is not workig properly')227 'moveAction method is not workig properly') 227 228 self.panel.moveAction('home', 'portal_tabs', -1) 228 229 self.assertEquals(pos('home'), 1, 229 'moveAction method is not workig properly')230 'moveAction method is not workig properly') 230 231 231 232 … … 237 238 self.loginAsPortalOwner() 238 239 panel = getMultiAdapter((self.portal, self.portal.REQUEST), 239 name='plonetabs-controlpanel')240 name='plonetabs-controlpanel') 240 241 # we need this to apply zope2 security (got from zope2 traverse method) 241 242 self.panel = panel.__of__(self.portal) … … 244 245 def test_interface(self): 245 246 self.failUnless(IPloneTabsControlPanel.implementedBy(ptp), 246 'PloneTabs control panel does not implement required interface.') 247 'PloneTabs control panel does not implement ' 248 'required interface.') 247 249 self.failUnless(verifyClass(IPloneTabsControlPanel, ptp), 248 'PloneTabs control panel does not implement required interface.') 250 'PloneTabs control panel does not implement ' 251 'required interface.') 249 252 250 253 def test_getPageTitle(self): 251 254 self.assertEquals(self.panel.getPageTitle(), 252 _(u"Portal Tabs Configuration"),253 'getPageTitle method is broken')255 _(u"Portal Tabs Configuration"), 256 'getPageTitle method is broken') 254 257 self.assertEquals(self.panel.getPageTitle(category='notexists'), 255 _(u"Plone '${cat_name}' Configuration",256 mapping={'cat_name': 'notexists'}),257 'getPageTitle method is broken')258 _(u"Plone '${cat_name}' Configuration", 259 mapping={'cat_name': 'notexists'}), 260 'getPageTitle method is broken') 258 261 259 262 def test_hasActions(self): … … 262 265 self.purgeActions() 263 266 self.failIf(method(), 264 'There should be no portal_tab actions in portal')267 'There should be no portal_tab actions in portal') 265 268 266 269 # setup our own actions 267 270 self.setupActions(self.tool) 268 271 self.failUnless(method(), 269 'There should be portal_tab actions in portal')272 'There should be portal_tab actions in portal') 270 273 271 274 def test_getPortalActions(self): … … 273 276 # purge any default portal actions 274 277 self.purgeActions() 275 self.assertEquals(len(method()), 0, 276 'There should be no actions inportal_tabs category.')278 self.assertEquals(len(method()), 0, 'There should be no actions in ' 279 'portal_tabs category.') 277 280 278 281 # setup our own actions 279 282 self.setupActions(self.tool) 280 283 self.assertEquals(len(method()), 2, 281 'There should be 2 actions in portal_tabs category.')284 'There should be 2 actions in portal_tabs category.') 282 285 283 286 # marginal arguments 284 287 self.assertEquals(len(method('notexistent_category')), 0, 285 'There should be no actions for not existed category.') 288 'There should be no actions for not existed ' 289 'category.') 286 290 287 291 def test_isGeneratedTabs(self): … … 304 308 self.purgeActions() 305 309 self.failIf('class="editform"' in method(), 306 'There should no be actions in actions list template.')310 'There should no be actions in actions list template.') 307 311 self.setupActions(self.tool) 308 312 self.failUnless('class="editform"' in method(), 309 'There are no actions in actions list template.')313 'There are no actions in actions list template.') 310 314 311 315 def test_getAutoGenereatedSection(self): 312 316 method = self.panel.getAutoGenereatedSection 313 317 self.failIf('<form' in method('user'), 314 'There should be no form in autogenerated tabs template '315 'for category other than portal_tabs.')318 'There should be no form in autogenerated tabs template ' 319 'for category other than portal_tabs.') 316 320 self.failUnless('<form' in method('portal_tabs'), 317 'There should be form in autogenerated tabs template '318 'for portal_tabs category.')321 'There should be form in autogenerated tabs template ' 322 'for portal_tabs category.') 319 323 320 324 def test_getGeneratedTabs(self): … … 331 335 self.purgeContent() 332 336 self.assertEquals(len(method()), 0, 333 'There should be no root elements for navigation.')337 'There should be no root elements for navigation.') 334 338 335 339 # now add some testing content 336 340 self.setupContent(self.portal) 337 self.assertEquals(len(method()), 2, 338 'There should be 2 elements inportal root for navigation.')341 self.assertEquals(len(method()), 2, 'There should be 2 elements in ' 342 'portal root for navigation.') 339 343 340 344 # now switch off autogeneration … … 342 346 sp.manage_changeProperties(disable_folder_sections=True) 343 347 self.assertEquals(len(method()), 0, 344 'There should be no root elements for navigation when '345 'tabs autogeneration is switched off.')348 'There should be no root elements for navigation ' 349 'when tabs autogeneration is switched off.') 346 350 347 351 def test_getCategories(self): … … 349 353 # purge any default portal actions 350 354 self.purgeActions() 351 self.assertEquals(len(method()), 0, 352 'There should be no categoriesin portal_actions tool.')355 self.assertEquals(len(method()), 0, 'There should be no categories ' 356 'in portal_actions tool.') 353 357 354 358 # now setup actions 355 359 self.setupActions(self.tool) 356 360 self.assertEquals(method(), ['portal_tabs', 'new_category'], 357 'There should be exactly 2 categories in portal_actions tool.') 361 'There should be exactly 2 categories in ' 362 'portal_actions tool.') 358 363 359 364 def test_portal_tabs(self): … … 362 367 self.purgeActions() 363 368 self.assertEquals(len(method()), 0, 364 'There should be no portal tabs.')369 'There should be no portal tabs.') 365 370 366 371 # cleanup memoize cache … … 372 377 self.setupActions(self.tool) 373 378 self.assertEquals(len(method()), 2, 374 'There should be 2 portal tabs.')379 'There should be 2 portal tabs.') 375 380 376 381 # add content 377 382 self.setupContent(self.portal) 378 383 self.assertEquals(len(method()), 4, 379 'There should be 4 portal tabs.')384 'There should be 4 portal tabs.') 380 385 381 386 def test_selected_portal_tab(self): 382 387 self.assertEquals(self.panel.selected_portal_tab(), 'index_html', 383 'index_html is not selected tab while being on configlet.') 388 'index_html is not selected tab while being on ' 389 'configlet.') 384 390 385 391 def test_test(self): 386 392 self.assertEquals(self.panel.test(True, 'true', 'false'), 'true', 387 'Test function does not work properly.')393 'Test function does not work properly.') 388 394 389 395 … … 395 401 self.loginAsPortalOwner() 396 402 panel = getMultiAdapter((self.portal, self.portal.REQUEST), 397 name='plonetabs-controlpanel')403 name='plonetabs-controlpanel') 398 404 # we need this to apply zope2 security (got from zope2 traverse method) 399 405 self.panel = panel.__of__(self.portal) … … 426 432 self.failUnless('id1' in self.tool.cat1.objectIds()) 427 433 self.failIf(postback, 428 'There should be redirect after successfull adding.')434 'There should be redirect after successfull adding.') 429 435 430 436 def test_manage_editAction(self): … … 445 451 self.failUnless('id_new' in self.tool.portal_tabs.objectIds()) 446 452 self.failIf(postback, 447 'There should be redirect after successfull edition.')453 'There should be redirect after successfull edition.') 448 454 449 455 form['category'] = 'non_existent' -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_erase.py
r3563 r3608 9 9 try: 10 10 # Plone < 4.3 11 from zope.app.component import hooks 11 from zope.app.component import hooks 12 12 setSite = hooks.setSite 13 13 setHooks = hooks.setHooks 14 14 except ImportError: 15 # Plone >= 4.3 15 # Plone >= 4.3 16 16 from zope.component.hooks import setSite, setHooks 17 17 … … 61 61 tool = getToolByName(self.portal, 'portal_actionicons') 62 62 icon_ids = [i._action_id for i in tool.listActionIcons()] 63 self.failIf('plonetabs' in icon_ids, 64 'There should be no plonetabsaction icon after uninstall.')63 self.failIf('plonetabs' in icon_ids, 'There should be no plonetabs ' 64 'action icon after uninstall.') 65 65 66 66 def test_controlPanel(self): 67 67 tool = getToolByName(self.portal, 'portal_controlpanel') 68 68 action_ids = [a.id for a in tool.listActions()] 69 self.failIf('plonetabs' in action_ids, 70 'There should be no plonetabsconfiglet after after uninstall.')69 self.failIf('plonetabs' in action_ids, 'There should be no plonetabs ' 70 'configlet after after uninstall.') 71 71 72 72 def test_cssRegistry(self): … … 74 74 css = tool.getResource('++resource++plonetabs.css') 75 75 self.failUnless(css is None, 76 'There should be no ++resource++plonetabs.css stylesheets after'77 'uninstall.')76 'There should be no ++resource++plonetabs.css ' 77 'stylesheets after uninstall.') 78 78 79 79 def test_jsRegistry(self): … … 82 82 effects = tool.getResource('++resource++pt_effects.js') 83 83 self.failUnless(effects is None, 84 'There should be no ++resource++pt_effects.js script after'85 'uninstall.')84 'There should be no ++resource++pt_effects.js script ' 85 'after uninstall.') 86 86 87 87 dad = tool.getResource('++resource++sa_dragdrop.js') 88 88 self.failUnless(dad is None, 89 'There should be no ++resource++sa_dragdrop.js script after'90 'uninstall.')89 'There should be no ++resource++sa_dragdrop.js script ' 90 'after uninstall.') 91 91 92 92 def test_kssRegistry(self): … … 94 94 kss = tool.getResource('++resource++plonetabs.kss') 95 95 self.failUnless(kss is None, 96 'There should be no ++resource++plonetabs.kss sheets after'97 'uninstall.')96 'There should be no ++resource++plonetabs.kss sheets ' 97 'after uninstall.') 98 98 kss = tool.getResource('++resource++plonetabsmode.kss') 99 99 self.failUnless(kss is None, 100 'There should be no ++resource++plonetabsmode.kss sheets after'101 'uninstall.')100 'There should be no ++resource++plonetabsmode.kss ' 101 'sheets after uninstall.') 102 102 103 103 def test_propertiesTool(self): 104 104 tool = getToolByName(self.portal, 'portal_properties') 105 105 self.failUnless(hasattr(tool, 'tabs_properties'), 106 'There is no tabs_properties sheet in portal properties tool'107 'after uninstall.')106 'There is no tabs_properties sheet in portal ' 107 'properties tool after uninstall.') 108 108 titles = tool.tabs_properties.getProperty('titles', None) 109 109 self.assertEquals(titles, 110 ('portal_tabs|Portal Tabs Configuration',111 'portal_footer|Portal Footer Configuration'),112 'titles plonetabs property was erased from portal_properties'113 'after uninstall.'114 )110 ('portal_tabs|Portal Tabs Configuration', 111 'portal_footer|Portal Footer Configuration'), 112 'titles plonetabs property was erased from ' 113 'portal_properties after uninstall.' 114 ) 115 115 116 116 def test_browserLayer(self): 117 117 layers = [o.__name__ for o in registered_layers()] 118 118 self.failIf('IPloneTabsProductLayer' in layers, 119 'There should be no quintagroup.plonetabs layer after uninstall.') 119 'There should be no quintagroup.plonetabs layer after' 120 ' uninstall.') 120 121 121 122 -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_setup.py
r3437 r3608 16 16 tool = getToolByName(self.portal, 'portal_actionicons') 17 17 icon_ids = [i._action_id for i in tool.listActionIcons()] 18 self.failUnless('plonetabs' in icon_ids, 19 'There is no plonetabs actionicon in actionicons tool.')18 self.failUnless('plonetabs' in icon_ids, 'There is no plonetabs action' 19 'icon in actionicons tool.') 20 20 21 21 def test_controlPanel(self): … … 23 23 action_ids = [a.id for a in tool.listActions()] 24 24 self.failUnless('plonetabs' in action_ids, 25 'There is no plonetabs action in control panel.')25 'There is no plonetabs action in control panel.') 26 26 27 27 def test_cssRegistry(self): 28 28 tool = getToolByName(self.portal, 'portal_css') 29 29 css = tool.getResource('++resource++plonetabs.css') 30 self.failIf(css is None, 31 'There is no ++resource++plonetabs.cssstylesheets registered.')30 self.failIf(css is None, 'There is no ++resource++plonetabs.css ' 31 'stylesheets registered.') 32 32 33 33 def test_jsRegistry(self): … … 36 36 prototype = tool.getResource('++resource++prototype.js') 37 37 self.failIf(prototype is None, 38 'There is no ++resource++prototype.js script registered.')38 'There is no ++resource++prototype.js script registered.') 39 39 self.failUnless(prototype._data['enabled'], 40 '++resource++prototype.js script is disabled.')40 '++resource++prototype.js script is disabled.') 41 41 42 42 effects = tool.getResource('++resource++pt_effects.js') 43 43 self.failIf(effects is None, 44 'There is no ++resource++pt_effects.js script registered.')44 'There is no ++resource++pt_effects.js script registered.') 45 45 46 46 dad = tool.getResource('++resource++sa_dragdrop.js') 47 self.failIf(dad is None, 48 'There is no ++resource++sa_dragdrop.jsscript registered.')47 self.failIf(dad is None, 'There is no ++resource++sa_dragdrop.js ' 48 'script registered.') 49 49 50 50 def test_kssRegistry(self): … … 52 52 kss = tool.getResource('++resource++plonetabs.kss') 53 53 self.failIf(kss is None, 54 'There is no ++resource++plonetabs.kss sheets registered.')54 'There is no ++resource++plonetabs.kss sheets registered.') 55 55 kss = tool.getResource('++resource++plonetabsmode.kss') 56 self.failIf(kss is None, 57 'There is no ++resource++plonetabsmode.ksssheets registered.')56 self.failIf(kss is None, 'There is no ++resource++plonetabsmode.kss ' 57 'sheets registered.') 58 58 59 59 def test_propertiesTool(self): 60 60 tool = getToolByName(self.portal, 'portal_properties') 61 self.failUnless(hasattr(tool, 'tabs_properties'), 62 'There is notabs_properties sheet in portal properties tool.')61 self.failUnless(hasattr(tool, 'tabs_properties'), 'There is no ' 62 'tabs_properties sheet in portal properties tool.') 63 63 titles = tool.tabs_properties.getProperty('titles', None) 64 64 self.assertEquals(titles, 65 ('portal_tabs|Portal Tabs Configuration',66 'portal_footer|Portal Footer Configuration'),67 'Site properties was not setup properly'68 )65 ('portal_tabs|Portal Tabs Configuration', 66 'portal_footer|Portal Footer Configuration'), 67 'Site properties was not setup properly' 68 ) 69 69 70 70 def test_browserLayerRegistered(self): 71 71 layers = [o.__name__ for o in registered_layers()] 72 self.failUnless('IPloneTabsProductLayer' in layers, 73 'There should bequintagroup.ploentabs browser layer registered.')72 self.failUnless('IPloneTabsProductLayer' in layers, 'There should be ' 73 'quintagroup.ploentabs browser layer registered.') 74 74 75 75 -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/utils.py
r3607 r3608 8 8 9 9 10 # TODO: Methods 'getViewletByName' and 'setupViewletByName' were copied 11 # from https://github.com/collective/collective.developermanual/blob/master/source/views/viewlets.rst#rendering-viewlet-by-name 10 # TODO: Methods 'getViewletByName' and 'setupViewletByName' were copied from 11 # https://github.com/collective/collective.developermanual/blob/master/source/ 12 # views/viewlets.rst#rendering-viewlet-by-name 12 13 # Better solution would be to use collective.fastview 13 14 # (http://svn.plone.org/svn/collective/collective.fastview/trunk/) … … 27 28 28 29 if v.provided == IViewlet: 29 # Note that we might have conflicting BrowserView with the same name,30 # thus we need to check for provided30 # Note that we might have conflicting BrowserView with the 31 # same name, thus we need to check for provided 31 32 if v.name == name: 32 33 return v … … 59 60 except TypeError: 60 61 # Bad constructor call parameters 61 raise RuntimeError("Unable to initialize viewlet %s. Factory method %s call failed." % (name, str(factory))) 62 raise RuntimeError("Unable to initialize viewlet %s. Factory " 63 "method %s call failed." % (name, str(factory))) 62 64 63 65 return viewlet
Note: See TracChangeset
for help on using the changeset viewer.