Changeset 3402 in products for quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests
- Timestamp:
- Apr 2, 2012 1:04:35 PM (12 years ago)
- Location:
- quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/__init__.py
r756 r3402 1 # -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/base.py
r865 r3402 19 19 #ztc.installProduct('Zope2Product') 20 20 21 21 22 @onsetup 22 23 def setup_package(): … … 31 32 _marker = object() 32 33 34 33 35 class PloneTabsTestCase(ptc.PloneTestCase): 34 36 """Common test base class""" 35 37 36 38 def afterSetUp(self): 37 39 # due to some reason plone.browserlayer is not marking REQUEST 38 40 # with installed products layer interfaces 39 # so I'm doing it manually here 41 # so I'm doing it manually here 40 42 class DummyEvent(object): 41 43 def __init__(self, request): 42 44 self.request = request 43 45 mark_layer(self.portal, DummyEvent(self.portal.REQUEST)) 44 46 45 47 def purgeCache(self, request): 46 48 annotations = IAnnotations(request) … … 48 50 if cache is not _marker: 49 51 del annotations['plone.memoize'] 50 52 51 53 def purgeActions(self): 52 54 for obj in self.tool.objectValues(): … … 56 58 #elif IActionCategory.providedBy(obj): 57 59 #obj.manage_delObjects(ids=obj.objectIds()) 58 60 59 61 def setupActions(self, parent, kids=PORTAL_ACTIONS): 60 62 ids = parent.objectIds() … … 68 70 if child.get('children', {}): 69 71 self.setupActions(getattr(parent, id), child['children']) 70 72 71 73 def purgeContent(self): 72 74 ids = [obj.id for obj in self.portal.listFolderContents()] 73 75 self.portal.manage_delObjects(ids=ids) 74 76 75 77 def setupContent(self, parent, kids=PORTAL_CONTENT): 76 78 ids = parent.objectIds() … … 80 82 if child.get('children', {}) and id in ids: 81 83 self.setupContent(getattr(parent, id), child['children']) 82 84 83 85 def _createType(self, container, portal_type, id, **kwargs): 84 86 """Helper method to create content objects""" 85 87 ttool = getToolByName(container, 'portal_types') 86 portal_catalog = 87 88 portal_catalog = getToolByName(container, 'portal_catalog') 89 88 90 fti = ttool.getTypeInfo(portal_type) 89 91 fti.constructInstance(container, id, **kwargs) 90 92 obj = getattr(container.aq_inner.aq_explicit, id) 91 93 92 94 # publish and reindex 93 95 #self._publish_item(portal, obj) -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/ecmaunits/__init__.py
r884 r3402 1 # -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/ecmaunits/ecmaview.py
r884 r3402 2 2 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile 3 3 from kss.core.tests.ecmaview import EcmaView as base 4 4 5 5 6 def absolute_dir(path): … … 7 8 return os.path.abspath(os.path.join(here, path)) 8 9 10 9 11 class EcmaView(base): 10 12 '''quintagroup.plonetabs js test view 11 13 12 14 This allows the runner.html to be used on this view. 13 15 -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/selenium/__init__.py
r818 r3402 1 # -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/selenium/zopeconfig.py
r818 r3402 14 14 # for your own programs, or otherwise you will need to change 15 15 # it later. The test suite creation interface will change in 16 # the next kss.demo versions. The plugin class (PloneDemos) 17 # will change in the next major KSS (and possibly Plone) version. 16 # the next kss.demo versions. The plugin class (PloneDemos) 17 # will change in the next major KSS (and possibly Plone) version. 18 18 # This configuration file will be kept up-to-date to these changes. 19 19 # … … 26 26 teardown = KSSSeleniumTestCase('uninstall-tabs.html') 27 27 28 28 29 class PloneTabsSeleniumKssTests(object): 29 30 implements(IResource) … … 33 34 selenium_tests = ( 34 35 KSSSeleniumTestSuite( 35 tests = KSSSeleniumTestDirectory('selenium_tests/run_as_testmanager'), 36 layer = PortalTabsLayer, 37 component = 'quintagroup.plonetabs', 38 application = 'quintagroup.plonetabs', 36 tests=KSSSeleniumTestDirectory('selenium_tests/' +\ 37 'run_as_testmanager'), 38 layer=PortalTabsLayer, 39 component='quintagroup.plonetabs', 40 application='quintagroup.plonetabs', 39 41 ), 40 42 ) -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_controlpanel.py
r917 r3402 10 10 from quintagroup.plonetabs import messageFactory as _ 11 11 from quintagroup.plonetabs.browser.interfaces import IPloneTabsControlPanel 12 from quintagroup.plonetabs.browser.plonetabs import PloneTabsControlPanel as ptp 12 from quintagroup.plonetabs.browser.plonetabs \ 13 import PloneTabsControlPanel as ptp 13 14 from quintagroup.plonetabs.tests.base import PloneTabsTestCase 14 15 from quintagroup.plonetabs.tests.data import PORTAL_ACTIONS 15 16 17 16 18 class TestControlPanelHelperMethods(PloneTabsTestCase): 17 19 """Test here configlet helper methods""" 18 19 20 def afterSetUp(self): 20 21 super(TestControlPanelHelperMethods, self).afterSetUp() … … 25 26 self.panel = panel.__of__(self.portal) 26 27 self.tool = getToolByName(self.portal, 'portal_actions') 27 28 28 29 def test_redirect(self): 29 30 response = self.portal.REQUEST.RESPONSE 30 31 method = self.panel.redirect 31 portal_url = 32 portal_url = getMultiAdapter((self.portal, self.portal.REQUEST), 32 33 name=u"plone_portal_state").portal_url() 33 34 url = '%s/@@plonetabs-controlpanel' % portal_url … … 35 36 self.assertEquals(response.headers.get('location', ''), url, 36 37 'Redirect method is not working properly.') 37 38 38 39 # check query string and anchor hash 39 40 method('http://quintagroup.com', 'q=test', 'hash_code') … … 41 42 'http://quintagroup.com?q=test#hash_code', 42 43 'Redirect method is not working properly.') 43 44 44 45 def test_fixExpression(self): 45 46 method = self.panel.fixExpression 46 47 self.assertEquals(method('/slash'), 'string:${portal_url}/slash') 47 self.assertEquals(method('https://test.com'), 'string:https://test.com') 48 self.assertEquals(method('https://test.com'), 49 'string:https://test.com') 48 50 self.assertEquals(method('python:True'), 'python:True') 49 51 self.assertEquals(method('hello'), 'string:${object_url}/hello') 50 52 51 53 def test_copyAction(self): 52 54 data = PORTAL_ACTIONS[0][1]['children'][0][1] … … 55 57 self.assertEquals(len(info.keys()), 6) 56 58 self.assertEquals(info['description'], 'The most important place') 57 59 58 60 def test_validateActionFields(self): 59 61 method = self.panel.validateActionFields … … 63 65 self.assertEquals(errors, {}, 64 66 'There should be no errors for valid data.') 65 66 bad_data = {'id': '',67 68 bad_data = {'id': '', 67 69 'title': ' ', 68 70 'available_expr': 'bad_type:test', 69 71 'url_expr': 'bad_type:test'} 70 72 71 73 # Revert PloneTestCase's optimization 72 74 # because this breaks our test … … 81 83 # rollback our patch 82 84 Expression.__init__ = optimized__init__ 83 85 84 86 self.assertEquals(len(errors.keys()), 4, 85 87 'validateActionFields method is not working properly.') 86 88 87 89 def test_processErrors(self): 88 90 method = self.panel.processErrors 89 errors = {'error': 'error message'}91 errors = {'error': 'error message'} 90 92 self.assertEquals(method(errors), errors, 91 93 'processErrors method is not working properly.') … … 93 95 {'pre_error_post': 'error message'}, 94 96 'processErrors method is not working properly.') 95 97 96 98 def test_parseEditForm(self): 97 99 method = self.panel.parseEditForm … … 110 112 'visible': True}), 111 113 'parseEditForm method is not working properly.') 112 114 113 115 del form['orig_id'] 114 116 self.failUnlessRaises(KeyError, method, form) 115 117 116 118 def test_parseAddForm(self): 117 119 method = self.panel.parseAddForm … … 129 131 'available_expr': 'expr2'}), 130 132 'parseAddForm method is not working properly.') 131 133 132 134 del form['id'] 133 135 self.failUnlessRaises(KeyError, method, form) 134 136 135 137 def test_getActionCategory(self): 136 138 method = self.panel.getActionCategory 137 139 self.purgeActions() 138 140 self.failUnlessRaises(KeyError, method, 'portal_tabs') 139 141 140 142 self.setupActions(self.tool) 141 143 self.assertEquals(method('portal_tabs').id, 'portal_tabs', 142 144 'getActionCategory is not working properly.') 143 145 144 146 def test_getOrCreateCategory(self): 145 147 method = self.panel.getOrCreateCategory … … 147 149 self.assertEquals(method('portal_tabs').id, 'portal_tabs', 148 150 'getOrCreateCategory is not working properly.') 149 151 150 152 def test_setSiteProperties(self): 151 153 self.panel.setSiteProperties(title='Test Title') … … 153 155 self.assertEquals(sp.getProperty('title'), 'Test Title', 154 156 'setSiteProperties method is not working properly.') 155 157 156 158 def test_renderViewlet(self): 157 159 # register test viewlet and it's manager … … 161 163 from zope.publisher.interfaces.browser import IDefaultBrowserLayer 162 164 from zope.publisher.interfaces.browser import IBrowserView 165 163 166 class TestViewlet(ViewletBase): 164 167 def __of__(self, obj): 165 168 return self 169 166 170 def render(self): 167 171 return 'test viewlet' 172 168 173 provideAdapter( 169 174 TestViewlet, … … 176 181 IViewletManager, 177 182 name=u'test_manager') 178 183 179 184 self.assertEquals( 180 185 self.panel.renderViewlet('test_manager', 'test_viewlet'), 181 186 'test viewlet', 182 187 'renderViewlet method is not workig properly') 183 188 184 189 def test_addAction(self): 185 190 self.purgeActions() 186 self.panel.addAction('new_category', {'id': 'id1', 'title':'Test'})191 self.panel.addAction('new_category', {'id': 'id1', 'title': 'Test'}) 187 192 self.failUnless('id1' in self.tool.new_category.objectIds(), 188 193 'addAction method is not workig properly') 189 194 190 195 def test_updateAction(self): 191 196 method = self.panel.updateAction 192 193 self.purgeActions() 194 self.failUnlessRaises(KeyError, method, 'id1', 'cat1', {'id': 'new'})195 197 198 self.purgeActions() 199 self.failUnlessRaises(KeyError, method, 'id1', 'cat1', {'id': 'new'}) 200 196 201 self.setupActions(self.tool) 197 202 # we need to commit transaction because … … 199 204 import transaction 200 205 transaction.savepoint() 201 method('home', 'portal_tabs', {'id': 'new_home'})206 method('home', 'portal_tabs', {'id': 'new_home'}) 202 207 self.failUnless('new_home' in self.tool.portal_tabs.objectIds(), 203 208 'updateAction method is not workig properly') 204 209 205 210 def test_deleteAction(self): 206 211 self.purgeActions() … … 209 214 self.failIf('home' in self.tool.portal_tabs.objectIds(), 210 215 'deleteAction method is not workig properly') 211 216 212 217 def test_moveAction(self): 213 218 self.purgeActions() … … 223 228 class TestControlPanelAPIMethods(PloneTabsTestCase): 224 229 """Test here interface methods of control panel class""" 225 230 226 231 def afterSetUp(self): 227 232 super(TestControlPanelAPIMethods, self).afterSetUp() … … 232 237 self.panel = panel.__of__(self.portal) 233 238 self.tool = getToolByName(self.portal, 'portal_actions') 234 239 235 240 def test_interface(self): 236 241 self.failUnless(IPloneTabsControlPanel.implementedBy(ptp), … … 238 243 self.failUnless(verifyClass(IPloneTabsControlPanel, ptp), 239 244 'PloneTabs control panel does not implement required interface.') 240 245 241 246 def test_getPageTitle(self): 242 247 self.assertEquals(self.panel.getPageTitle(), … … 247 252 mapping={'cat_name': 'notexists'}), 248 253 'getPageTitle method is broken') 249 254 250 255 def test_hasActions(self): 251 256 method = self.panel.hasActions … … 254 259 self.failIf(method(), 255 260 'There should be no portal_tab actions in portal') 256 261 257 262 # setup our own actions 258 263 self.setupActions(self.tool) 259 264 self.failUnless(method(), 260 265 'There should be portal_tab actions in portal') 261 266 262 267 def test_getPortalActions(self): 263 268 method = self.panel.getPortalActions … … 266 271 self.assertEquals(len(method()), 0, 267 272 'There should be no actions in portal_tabs category.') 268 273 269 274 # setup our own actions 270 275 self.setupActions(self.tool) 271 276 self.assertEquals(len(method()), 2, 272 277 'There should be 2 actions in portal_tabs category.') 273 278 274 279 # marginal arguments 275 280 self.assertEquals(len(method('notexistent_category')), 0, 276 281 'There should be no actions for not existed category.') 277 282 278 283 def test_isGeneratedTabs(self): 279 284 method = self.panel.isGeneratedTabs … … 282 287 sp.manage_changeProperties(disable_folder_sections=True) 283 288 self.failIf(method(), 'But folder sections are disabled...') 284 289 285 290 def test_isNotFoldersGenerated(self): 286 291 method = self.panel.isNotFoldersGenerated … … 289 294 sp.manage_changeProperties(disable_nonfolderish_sections=True) 290 295 self.failIf(method(), 'But non folderish sections are disabled...') 291 296 292 297 def test_getActionsList(self): 293 298 method = self.panel.getActionsList … … 299 304 self.failUnless('class="editform"' in method(), 300 305 'There are no actions in actions list template.') 301 306 302 307 def test_getAutoGenereatedSection(self): 303 308 method = self.panel.getAutoGenereatedSection … … 308 313 'There should be form in autogenerated tabs template ' 309 314 'for portal_tabs category.') 310 315 311 316 def test_getGeneratedTabs(self): 312 317 self.panel.getGeneratedTabs() … … 316 321 'Mon, 26 Jul 1996 05:00:00 GMT', 317 322 'Expiration header is not set properly.') 318 323 319 324 def test_getRootTabs(self): 320 325 method = self.panel.getRootTabs … … 323 328 self.assertEquals(len(method()), 0, 324 329 'There should be no root elements for navigation.') 325 330 326 331 # now add some testing content 327 332 self.setupContent(self.portal) 328 333 self.assertEquals(len(method()), 2, 329 334 'There should be 2 elements in portal root for navigation.') 330 335 331 336 # now switch off autogeneration 332 337 sp = getToolByName(self.portal, 'portal_properties').site_properties … … 335 340 'There should be no root elements for navigation when ' 336 341 'tabs autogeneration is switched off.') 337 342 338 343 def test_getCategories(self): 339 344 method = self.panel.getCategories … … 342 347 self.assertEquals(len(method()), 0, 343 348 'There should be no categories in portal_actions tool.') 344 349 345 350 # now setup actions 346 351 self.setupActions(self.tool) 347 352 self.assertEquals(method(), ['portal_tabs', 'new_category'], 348 353 'There should be exactly 2 categories in portal_actions tool.') 349 354 350 355 def test_portal_tabs(self): 351 356 method = self.panel.portal_tabs … … 354 359 self.assertEquals(len(method()), 0, 355 360 'There should be no portal tabs.') 356 361 357 362 # cleanup memoize cache 358 363 # cause actions method of portal context state is caching it's 359 364 # results in request and we have the same request for every call 360 365 self.purgeCache(self.portal.REQUEST) 361 366 362 367 # add actions 363 368 self.setupActions(self.tool) 364 369 self.assertEquals(len(method()), 2, 365 370 'There should be 2 portal tabs.') 366 371 367 372 # add content 368 373 self.setupContent(self.portal) 369 374 self.assertEquals(len(method()), 4, 370 375 'There should be 4 portal tabs.') 371 376 372 377 def test_selected_portal_tab(self): 373 378 self.assertEquals(self.panel.selected_portal_tab(), 'index_html', … … 381 386 class TestControlPanelManageMethods(PloneTabsTestCase): 382 387 """Test here management methods of control panel class""" 383 388 384 389 def afterSetUp(self): 385 390 super(TestControlPanelManageMethods, self).afterSetUp() … … 390 395 self.panel = panel.__of__(self.portal) 391 396 self.tool = getToolByName(self.portal, 'portal_actions') 392 397 393 398 # purge standard set of actions and set our own testing ones 394 399 self.purgeActions() 395 400 self.setupActions(self.tool) 396 401 397 402 def test_manage_setAutogeneration(self): 398 403 self.setupContent(self.portal) … … 405 410 self.failIf(sp.disable_folder_sections) 406 411 self.failUnless(sp.disable_nonfolderish_sections) 407 412 408 413 def test_manage_addAction(self): 409 414 self.purgeActions() … … 418 423 self.failIf(postback, 419 424 'There should be redirect after successfull adding.') 420 425 421 426 def test_manage_editAction(self): 422 427 method = self.panel.manage_editAction … … 432 437 import transaction 433 438 transaction.savepoint() 434 439 435 440 postback = method(form, {}) 436 441 self.failUnless('id_new' in self.tool.portal_tabs.objectIds()) 437 442 self.failIf(postback, 438 443 'There should be redirect after successfull edition.') 439 444 440 445 form['category'] = 'non_existent' 441 446 self.failUnlessRaises(KeyError, method, form, {}) 442 447 443 448 def test_manage_deleteAction(self): 444 449 self.purgeActions() … … 453 458 self.panel.manage_deleteAction(form, {}) 454 459 self.failIf('home' in self.tool.portal_tabs.objectIds()) 455 460 456 461 def test_manage_moveUpAction(self): 457 462 self.purgeActions() … … 467 472 self.assertEquals( 468 473 self.tool.portal_tabs.getObjectPosition('quintagroup'), 0) 469 474 470 475 def test_manage_moveDownAction(self): 471 476 self.purgeActions() … … 487 492 suite.addTest(unittest.makeSuite(TestControlPanelAPIMethods)) 488 493 suite.addTest(unittest.makeSuite(TestControlPanelManageMethods)) 489 494 490 495 # these tests are implemented as Selenium KSS Tests 491 496 # using kss.demo package, and KSS plugins are tested by means of -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_erase.py
r3395 r3402 15 15 16 16 from quintagroup.plonetabs.tests.base import PloneTabsTestCase 17 17 18 18 19 class TestErase(PloneTabsTestCase): … … 39 40 product_name = 'quintagroup.plonetabs' 40 41 if tool.isProductInstalled(product_name): 41 tool.uninstallProducts([product_name, ])42 tool.uninstallProducts([product_name, ]) 42 43 43 44 # drop elevated perms … … 49 50 def afterSetUp(self): 50 51 self.loginAsPortalOwner() 51 52 52 53 def test_actionIcons(self): 53 54 tool = getToolByName(self.portal, 'portal_actionicons') … … 55 56 self.failIf('plonetabs' in icon_ids, 56 57 'There should be no plonetabs action icon after uninstall.') 57 58 58 59 def test_controlPanel(self): 59 60 tool = getToolByName(self.portal, 'portal_controlpanel') … … 61 62 self.failIf('plonetabs' in action_ids, 62 63 'There should be no plonetabs configlet after after uninstall.') 63 64 64 65 def test_cssRegistry(self): 65 66 tool = getToolByName(self.portal, 'portal_css') … … 68 69 'There should be no ++resource++plonetabs.css stylesheets after' 69 70 ' uninstall.') 70 71 71 72 def test_jsRegistry(self): 72 73 tool = getToolByName(self.portal, 'portal_javascripts') 73 74 74 75 effects = tool.getResource('++resource++pt_effects.js') 75 76 self.failUnless(effects is None, 76 77 'There should be no ++resource++pt_effects.js script after' 77 78 ' uninstall.') 78 79 79 80 dad = tool.getResource('++resource++sa_dragdrop.js') 80 81 self.failUnless(dad is None, … … 92 93 'There should be no ++resource++plonetabsmode.kss sheets after' 93 94 ' uninstall.') 94 95 95 96 def test_propertiesTool(self): 96 97 tool = getToolByName(self.portal, 'portal_properties') … … 105 106 ' after uninstall.' 106 107 ) 107 108 108 109 def test_browserLayer(self): 109 110 sm = getSiteManager(self.portal) … … 112 113 'There should be no quintagroup.plonetabs layer after uninstall.') 113 114 115 114 116 def test_suite(): 115 117 suite = unittest.TestSuite() -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_setup.py
r872 r3402 9 9 from quintagroup.plonetabs.tests.base import PloneTabsTestCase 10 10 11 11 12 class TestSetup(PloneTabsTestCase): 12 13 13 14 def afterSetUp(self): 14 15 self.loginAsPortalOwner() 15 16 16 17 def test_actionIcons(self): 17 18 tool = getToolByName(self.portal, 'portal_actionicons') … … 19 20 self.failUnless('plonetabs' in icon_ids, 20 21 'There is no plonetabs action icon in actionicons tool.') 21 22 22 23 def test_controlPanel(self): 23 24 tool = getToolByName(self.portal, 'portal_controlpanel') … … 25 26 self.failUnless('plonetabs' in action_ids, 26 27 'There is no plonetabs action in control panel.') 27 28 28 29 def test_cssRegistry(self): 29 30 tool = getToolByName(self.portal, 'portal_css') … … 31 32 self.failIf(css is None, 32 33 'There is no ++resource++plonetabs.css stylesheets registered.') 33 34 34 35 def test_jsRegistry(self): 35 36 tool = getToolByName(self.portal, 'portal_javascripts') 36 37 37 38 prototype = tool.getResource('++resource++prototype.js') 38 39 self.failIf(prototype is None, … … 40 41 self.failUnless(prototype._data['enabled'], 41 42 '++resource++prototype.js script is disabled.') 42 43 43 44 effects = tool.getResource('++resource++pt_effects.js') 44 45 self.failIf(effects is None, 45 46 'There is no ++resource++pt_effects.js script registered.') 46 47 47 48 dad = tool.getResource('++resource++sa_dragdrop.js') 48 49 self.failIf(dad is None, … … 57 58 self.failIf(kss is None, 58 59 'There is no ++resource++plonetabsmode.kss sheets registered.') 59 60 60 61 def test_propertiesTool(self): 61 62 tool = getToolByName(self.portal, 'portal_properties') … … 68 69 'Site properties was not setup properly' 69 70 ) 70 71 71 72 def test_browserLayerRegistered(self): 72 73 sm = getSiteManager(self.portal) … … 75 76 'There should be quintagroup.ploentabs browser layer registered.') 76 77 78 77 79 def test_suite(): 78 80 suite = unittest.TestSuite()
Note: See TracChangeset
for help on using the changeset viewer.