Changeset 3402 in products
- Timestamp:
- Apr 2, 2012 1:04:35 PM (12 years ago)
- Location:
- quintagroup.plonetabs/branches/tests
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/Extensions/Install.py
r865 r3402 14 14 ) 15 15 16 16 17 def install(self, reinstall=False): 17 18 """Install a set of products (which themselves may either use Install.py 18 19 or GenericSetup extension profiles for their configuration) and then 19 20 install a set of extension profiles. 20 21 21 22 One of the extension profiles we install is that of this product. This 22 23 works because an Install.py installation script (such as this one) takes 23 precedence over extension profiles for the same product in 24 portal_quickinstaller. 25 24 precedence over extension profiles for the same product in 25 portal_quickinstaller. 26 26 27 We do this because it is not possible to install other products during 27 28 the execution of an extension profile (i.e. we cannot do this during 28 29 the importVarious step for this profile). 29 30 """ 30 31 31 32 portal_quickinstaller = getToolByName(self, 'portal_quickinstaller') 32 33 portal_setup = getToolByName(self, 'portal_setup') … … 39 40 portal_quickinstaller.installProduct(product) 40 41 transaction.savepoint() 41 42 42 43 for extension_id in EXTENSION_PROFILES: 43 portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, purge_old=False) 44 portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, 45 purge_old=False) 44 46 product_name = extension_id.split(':')[0] 45 47 portal_quickinstaller.notifyInstalled(product_name) 46 48 transaction.savepoint() 47 49 50 48 51 def uninstall(self): 49 52 portal_setup = getToolByName(self, 'portal_setup') 50 53 for extension_id in UNINSTALL_PROFILES: 51 portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, purge_old=False) 54 portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, 55 purge_old=False) 52 56 product_name = extension_id.split(':')[0] 53 57 transaction.savepoint() -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/Extensions/__init__.py
r865 r3402 1 # -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/__init__.py
r873 r3402 3 3 messageFactory = MessageFactory('quintagroup.plonetabs') 4 4 5 5 6 def initialize(context): 6 7 pass -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/browser/__init__.py
r43 r3402 1 # I'm a package -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/browser/interfaces.py
r775 r3402 1 1 from zope.interface import Interface, Attribute 2 2 3 3 4 class IPloneTabsControlPanel(Interface): 4 5 """Configlet for managing portal_actions, quintagroup.plonetabs""" 5 6 6 7 prefix = Attribute('prefix', 'Prefix to apply on edit forms') 7 8 sufix = Attribute('sufix', 'Sufix to apply on edit forms') 8 9 9 10 def getPageTitle(category='portal_tabs'): 10 11 """Return Title for configlet page for given category""" 11 12 12 13 def hasActions(category="portal_tabs"): 13 14 """Whether there are actions in portal_actions with given category""" 14 15 15 16 def getPortalActions(category="portal_tabs"): 16 17 """Return portal actions with given category""" 17 18 18 19 def isGeneratedTabs(): 19 20 """Whether disable_folder_section field is turned off""" 20 21 21 22 def isNotFoldersGenerated(): 22 23 """Whether disable_nonfolderish_sections field is turned off""" 23 24 24 25 def getActionsList(category="portal_tabs"): 25 26 """Return html code for actions list with given category""" 26 27 27 28 def getAutoGenereatedSection(cat_name, errors): 28 29 """Return html code for all autogenerated section""" 29 30 30 31 def getGeneratedTabs(): 31 32 """Return html code for autogenerated tabs""" 32 33 33 34 def getRootTabs(): 34 35 """Return portal root elements""" 35 36 36 37 def getCategories(): 37 38 """Return list of categories contained in portal_actions tool""" 38 39 39 40 def portal_tabs(): 40 41 """See global-sections viewlet""" 41 42 42 43 def selected_portal_tab(): 43 44 """See global-sections viewlet""" 44 45 45 46 def test(condition, ifTrue, ifFalse): 46 47 """Instead of test function in skins page templates""" 47 -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/browser/plonetabs.py
r3401 r3402 38 38 39 39 cookie_name = 'ploneTabsMode' 40 40 41 41 42 class PloneTabsControlPanel(PloneKSSView): … … 148 149 IStatusMessage(self.request).addStatusMessage( 149 150 _(u"'${id}' action successfully added.", 150 mapping={'id': action.id}), type="info")151 mapping={'id': action.id}), type="info") 151 152 self.redirect(search="category=%s" % cat_name) 152 153 return False … … 179 180 else: 180 181 errs.update(self.processErrors(errors, 181 sufix='_%s' % id)) # add edit form sufix to error ids182 sufix='_%s' % id)) # add edit form sufix to error ids 182 183 IStatusMessage(self.request).addStatusMessage( 183 184 _(u"Please correct the indicated errors."), type="error") … … 214 215 self.moveAction(id, cat_name, steps=1) 215 216 IStatusMessage(self.request).addStatusMessage( 216 217 _(u"'${id}' action moved up.", mapping={'id': id}), type="info") 217 218 self.redirect(search="category=%s" % cat_name) 218 219 return False … … 247 248 """Redirect to @@plonetabs-controlpanel configlet""" 248 249 if not url: 249 portal_url = 250 portal_url = getMultiAdapter((self.context, self.request), 250 251 name=u"plone_portal_state").portal_url() 251 252 url = '%s/%s' % (portal_url, "@@plonetabs-controlpanel") … … 302 303 """See interface""" 303 304 tool = getToolByName(self.context, "portal_actions") 304 return len(tool.listActions(categories=[category, ])) > 0305 return len(tool.listActions(categories=[category, ])) > 0 305 306 306 307 def getPortalActions(self, category="portal_tabs"): … … 322 323 site_properties = getToolByName(self.context, 323 324 "portal_properties").site_properties 324 return not site_properties.getProperty("disable_folder_sections", False) 325 return not site_properties.getProperty("disable_folder_sections", 326 False) 325 327 326 328 def isNotFoldersGenerated(self): … … 364 366 query = {} 365 367 rootPath = getNavigationRoot(context) 366 query['path'] = {'query' : rootPath, 'depth': 1}368 query['path'] = {'query': rootPath, 'depth': 1} 367 369 query['portal_type'] = utils.typesToList(context) 368 370 … … 388 390 excludedIds = {} 389 391 for id in idsNotToList: 390 excludedIds[id] =1392 excludedIds[id] = 1 391 393 392 394 rawresult = portal_catalog.searchResults(**query) … … 396 398 if not excludedIds.has_key(item.getId): 397 399 id, item_url = get_view_url(item) 398 data = {'name' 399 'id' 400 'url' 400 data = {'name': utils.pretty_title_or_id(context, item), 401 'id': id, 402 'url': item_url, 401 403 'description': item.Description, 402 'exclude_from_nav' 404 'exclude_from_nav': item.exclude_from_nav} 403 405 result.append(data) 404 406 … … 428 430 actions = getMultiAdapter((self.context, self.request), 429 431 name=u'plone_context_state').actions() 430 try: 431 # Plone 4 and higher 432 import plone.app.upgrade 432 try: 433 # Plone 4 and higher 434 import plone.app.upgrade 433 435 if 'portal_tabs' in actions: 434 436 actions_tabs = actions['portal_tabs'] 435 437 else: 436 438 actions_tabs = [] 437 except ImportError: 439 except ImportError: 438 440 actions_tabs = actions 439 441 … … 519 521 ksscore = self.getCommandSet("core") 520 522 content = self.getGeneratedTabs() 521 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), content) 523 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), 524 content) 522 525 523 526 # update global-sections viewlet … … 554 557 value="invisible") 555 558 message = _(u"'${id}' object was included into navigation.", 556 mapping={'id': obj_id})559 mapping={'id': obj_id}) 557 560 else: 558 561 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 559 562 message = _(u"'${id}' object was excluded from navigation.", 560 mapping={'id': obj_id})563 mapping={'id': obj_id}) 561 564 562 565 # update global-sections viewlet … … 580 583 value="invisible") 581 584 message = _(u"'${id}' action is now visible.", 582 mapping={'id': act_id})585 mapping={'id': act_id}) 583 586 else: 584 587 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 585 588 message = _(u"'${id}' action is now invisible.", 586 mapping={'id': act_id})589 mapping={'id': act_id}) 587 590 self.updatePage(cat_name) 588 591 … … 608 611 # issue portal status message 609 612 self.kss_issueMessage(_(u"'${id}' action successfully removed.", 610 mapping={'id': act_id}))613 mapping={'id': act_id})) 611 614 612 615 @kssaction … … 627 630 # update client 628 631 # add one more action to actions list 629 content = self.getActionsList(category=cat_name, tabs=[action,]) 630 ksscore.insertHTMLAsLastChild(ksscore.getHtmlIdSelector('tabslist'), 631 content) 632 content = self.getActionsList(category=cat_name, tabs=[action, ]) 633 ksscore.insertHTMLAsLastChild( 634 ksscore.getHtmlIdSelector('tabslist'), 635 content) 632 636 633 637 # update reorder controls … … 652 656 653 657 message = _(u"'${id}' action successfully added.", 654 mapping={'id': action.id})658 mapping={'id': action.id}) 655 659 msgtype = "info" 656 660 … … 661 665 if errors.has_key('id') or errors.has_key('available_expr'): 662 666 self.kss_toggleCollapsible( 663 664 667 ksscore.getCssSelector('form[name=addaction_form] ' 668 '.headerAdvanced'), collapse='false') 665 669 666 670 message = _(u"Please correct the indicated errors.") … … 684 688 # collapse advanced section 685 689 self.kss_toggleCollapsible( 686 687 collapse='true')690 ksscore.getCssSelector('form[name=addaction_form] .headerAdvanced'), 691 collapse='true') 688 692 689 693 # reset form inputs … … 711 715 # update client 712 716 ksscore = self.getCommandSet("core") 713 content = self.getActionsList(category=cat_name, tabs=[action_info, ])717 content = self.getActionsList(category=cat_name, tabs=[action_info, ]) 714 718 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 715 719 … … 728 732 # update client 729 733 ksscore = self.getCommandSet("core") 730 content = self.getActionsList(category=cat_name, tabs=[action, ])734 content = self.getActionsList(category=cat_name, tabs=[action, ]) 731 735 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 732 736 … … 755 759 # update client 756 760 # replace action item with updated one 757 content = self.getActionsList(category=cat_name, tabs=[action, ])761 content = self.getActionsList(category=cat_name, tabs=[action, ]) 758 762 ksscore.replaceHTML(ksscore.getHtmlIdSelector(html_id), content) 759 763 760 764 message = _(u"'${id}' action successfully updated.", 761 mapping={'id': action.id})765 mapping={'id': action.id}) 762 766 msgtype = "info" 763 767 … … 826 830 def copyAction(self, action): 827 831 """Copy action to dictionary""" 828 action_info = {'description': action.description}832 action_info = {'description': action.description} 829 833 for attr in ACTION_ATTRS: 830 834 action_info[attr] = getattr(action, attr) … … 848 852 chooser.checkName(data['id'], self.context) 849 853 except Exception, e: 850 errors['id'] = self._formatError(e, **{'id': data['id']})854 errors['id'] = self._formatError(e, **{'id': data['id']}) 851 855 852 856 # validate action name … … 1007 1011 '.error-container' % (id, UI_ATTRS.get(name, name))) 1008 1012 else: 1009 field_selector = ksscore.getCssSelector('form[name=addaction_form] ' 1013 field_selector = ksscore.getCssSelector('form' +\ 1014 '[name=addaction_form] ' 1010 1015 '.field-%s' % UI_ATTRS.get(name, name)) 1011 1016 field_error_selector = ksscore.getCssSelector('form[name=' … … 1068 1073 """"Issues portal status message and removes it afte 10 seconds""" 1069 1074 ksscore = self.getCommandSet('core') 1070 self.getCommandSet('plone').issuePortalMessage(message, msgtype=msgtype) 1075 self.getCommandSet('plone').issuePortalMessage(message, 1076 msgtype=msgtype) 1071 1077 self.kss_timeout( 1072 1078 ksscore.getHtmlIdSelector('kssPortalMessage'), … … 1123 1129 """Delete action with given id from given category""" 1124 1130 category = self.getActionCategory(cat_name) 1125 category.manage_delObjects(ids=[id, ])1131 category.manage_delObjects(ids=[id, ]) 1126 1132 return True 1127 1133 … … 1131 1137 category = self.getActionCategory(cat_name) 1132 1138 if steps > 0: 1133 category.moveObjectsUp([id, ], steps)1139 category.moveObjectsUp([id, ], steps) 1134 1140 else: 1135 category.moveObjectsDown([id, ], abs(steps))1141 category.moveObjectsDown([id, ], abs(steps)) 1136 1142 return True 1137 1143 return False … … 1176 1182 #ksszope = self.getCommandSet("zope") 1177 1183 #ksszope.refreshViewlet( 1178 1179 1180 1184 #self.getCommandSet("core").getHtmlIdSelector("portal-siteactions"), 1185 #"plone.portalheader", 1186 #"plone.site_actions") 1181 1187 1182 1188 def updateUserPageSection(self): … … 1189 1195 "plone.personal_bar") 1190 1196 1197 1191 1198 class PloneTabsMode(BrowserView): 1192 1199 -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/config.py
r478 r3402 1 1 PROPERTY_SHEET = "tabs_properties" 2 FIELD_NAME 2 FIELD_NAME = "titles" -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/interfaces.py
r815 r3402 1 1 from zope.interface import Interface 2 2 3 3 4 class IPloneTabsProductLayer(Interface): -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/plugins/__init__.py
r43 r3402 1 # I'm a package -
quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/setuphandlers.py
r865 r3402 1 1 from Products.CMFCore.utils import getToolByName 2 2 3 3 4 def cleanUpControlPanel(portal, out): … … 7 8 out.append('plonetabs configlet unregistered.') 8 9 10 9 11 def uninstall(context): 10 12 # Only run step if a flag file is present (e.g. not an extension profile) … … 13 15 out = [] 14 16 site = context.getSite() 15 17 16 18 cleanUpControlPanel(site, out) -
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() -
quintagroup.plonetabs/branches/tests/setup.py
r3401 r3402 12 12 open(os.path.join("docs", "HISTORY.txt")).read(), 13 13 14 # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers 14 # Get more strings from 15 # http://www.python.org/pypi?%3Aaction=list_classifiers 15 16 classifiers=[ 16 17 "Framework :: Plone", … … 23 24 author='"Quintagroup": http://quintagroup.com/', 24 25 author_email='support@quintagroup.com', 25 url='http://quintagroup.com/services/plone-development/products/plone-tabs', 26 url='http://quintagroup.com/' +\ 27 'services/plone-development/products/plone-tabs', 26 28 license='GPL', 27 29 packages=find_packages(exclude=['ez_setup']),
Note: See TracChangeset
for help on using the changeset viewer.