Changeset 3437 in products for quintagroup.plonetabs/trunk
- Timestamp:
- Apr 20, 2012 10:04:56 AM (12 years ago)
- Location:
- quintagroup.plonetabs/trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonetabs/trunk
- Property svn:mergeinfo
-
old new 1 1 /quintagroup.plonetabs/branches/plone4:3076-3243 2 /quintagroup.plonetabs/branches/tests:3394-3436
-
- Property svn:mergeinfo
-
quintagroup.plonetabs/trunk/docs/HISTORY.txt
r3382 r3437 2 2 ========= 3 3 4 0.7.1-dev (unreleased) 5 ---------------------- 6 * Updated code according with pep8, pylint, pyflakes 7 [potar] 8 9 * Fixed tests and compatibility with Plone 3 (added plone detecting) 10 [potar] 11 12 * Added plone.browserlayer to install_requires (setup.py) 13 [potar] 14 4 15 0.7 - (12-03-2012) 5 ------------------ -16 ------------------ 6 17 * Updated permissions. Starting from Plone 4.1 it is necessary 7 18 to import permissions.zcml from Products.CMFCore. -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/Extensions/Install.py
r865 r3437 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)52 product_name = extension_id.split(':')[0]54 portal_setup.runAllImportStepsFromProfile('profile-%s' % extension_id, 55 purge_old=False) 53 56 transaction.savepoint() -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/Extensions/__init__.py
r865 r3437 1 # -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/__init__.py
r873 r3437 3 3 messageFactory = MessageFactory('quintagroup.plonetabs') 4 4 5 5 6 def initialize(context): 6 7 pass -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/__init__.py
r43 r3437 1 # I'm a package -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/interfaces.py
r775 r3437 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/trunk/quintagroup/plonetabs/browser/plonetabs.py
r3244 r3437 24 24 from Products.statusmessages.interfaces import IStatusMessage 25 25 26 from quintagroup.plonetabs.config import *26 from quintagroup.plonetabs.config import PROPERTY_SHEET, FIELD_NAME 27 27 from quintagroup.plonetabs import messageFactory as _ 28 28 from interfaces import IPloneTabsControlPanel … … 39 39 cookie_name = 'ploneTabsMode' 40 40 41 41 42 class PloneTabsControlPanel(PloneKSSView): 42 43 … … 60 61 postback = True 61 62 errors = {} 62 context = aq_inner(self.context)63 63 64 64 form = self.request.form 65 action = form.get("action", "")66 65 submitted = form.get('form.submitted', False) 67 66 … … 148 147 IStatusMessage(self.request).addStatusMessage( 149 148 _(u"'${id}' action successfully added.", 150 mapping={'id': action.id}), type="info")149 mapping={'id': action.id}), type="info") 151 150 self.redirect(search="category=%s" % cat_name) 152 151 return False … … 179 178 else: 180 179 errs.update(self.processErrors(errors, 181 sufix='_%s' % id)) # add edit form sufix to error ids180 sufix='_%s' % id)) # add edit form sufix to error ids 182 181 IStatusMessage(self.request).addStatusMessage( 183 182 _(u"Please correct the indicated errors."), type="error") … … 214 213 self.moveAction(id, cat_name, steps=1) 215 214 IStatusMessage(self.request).addStatusMessage( 216 215 _(u"'${id}' action moved up.", mapping={'id': id}), type="info") 217 216 self.redirect(search="category=%s" % cat_name) 218 217 return False … … 247 246 """Redirect to @@plonetabs-controlpanel configlet""" 248 247 if not url: 249 portal_url = 248 portal_url = getMultiAdapter((self.context, self.request), 250 249 name=u"plone_portal_state").portal_url() 251 250 url = '%s/%s' % (portal_url, "@@plonetabs-controlpanel") … … 302 301 """See interface""" 303 302 tool = getToolByName(self.context, "portal_actions") 304 return len(tool.listActions(categories=[category, ])) > 0303 return len(tool.listActions(categories=[category, ])) > 0 305 304 306 305 def getPortalActions(self, category="portal_tabs"): … … 322 321 site_properties = getToolByName(self.context, 323 322 "portal_properties").site_properties 324 return not site_properties.getProperty("disable_folder_sections", False) 323 return not site_properties.getProperty("disable_folder_sections", 324 False) 325 325 326 326 def isNotFoldersGenerated(self): … … 364 364 query = {} 365 365 rootPath = getNavigationRoot(context) 366 query['path'] = {'query' : rootPath, 'depth': 1}366 query['path'] = {'query': rootPath, 'depth': 1} 367 367 query['portal_type'] = utils.typesToList(context) 368 368 … … 388 388 excludedIds = {} 389 389 for id in idsNotToList: 390 excludedIds[id] =1390 excludedIds[id] = 1 391 391 392 392 rawresult = portal_catalog.searchResults(**query) … … 396 396 if not excludedIds.has_key(item.getId): 397 397 id, item_url = get_view_url(item) 398 data = {'name' 399 'id' 400 'url' 398 data = {'name': utils.pretty_title_or_id(context, item), 399 'id': id, 400 'url': item_url, 401 401 'description': item.Description, 402 'exclude_from_nav' 402 'exclude_from_nav': item.exclude_from_nav} 403 403 result.append(data) 404 404 … … 426 426 def portal_tabs(self): 427 427 """See global-sections viewlet""" 428 actions = context_state = getMultiAdapter((self.context, self.request), 429 name=u"plone_context_state").actions() 428 actions = getMultiAdapter((self.context, self.request), 429 name=u'plone_context_state').actions() 430 actions_tabs = [] 431 try: 432 # Plone 4 and higher 433 import plone.app.upgrade 434 plone.app.upgrade # pyflakes 435 except ImportError: 436 actions_tabs = actions 437 if not actions_tabs and 'portal_tabs' in actions: 438 actions_tabs = actions['portal_tabs'] 439 430 440 portal_tabs_view = getMultiAdapter((self.context, self.request), 431 441 name="portal_tabs_view") 432 if 'portal_tabs' in actions:433 actions_tabs = actions['portal_tabs']434 else:435 actions_tabs = []436 442 return portal_tabs_view.topLevelTabs(actions=actions_tabs) 437 443 … … 513 519 ksscore = self.getCommandSet("core") 514 520 content = self.getGeneratedTabs() 515 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), content) 521 ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), 522 content) 516 523 517 524 # update global-sections viewlet … … 531 538 532 539 if obj_id not in portal.objectIds(): 533 raise KSSExplicitError, \ 534 _(u"Object with '${id}' id doesn't exist in portal root.", 535 mapping={'id': obj_id}) 540 raise KSSExplicitError("Object with %s id doesn't" +\ 541 " exist in portal root." % obj_id) 536 542 537 543 if checked == '1': … … 548 554 value="invisible") 549 555 message = _(u"'${id}' object was included into navigation.", 550 mapping={'id': obj_id})556 mapping={'id': obj_id}) 551 557 else: 552 558 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 553 559 message = _(u"'${id}' object was excluded from navigation.", 554 mapping={'id': obj_id})560 mapping={'id': obj_id}) 555 561 556 562 # update global-sections viewlet … … 574 580 value="invisible") 575 581 message = _(u"'${id}' action is now visible.", 576 mapping={'id': act_id})582 mapping={'id': act_id}) 577 583 else: 578 584 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 579 585 message = _(u"'${id}' action is now invisible.", 580 mapping={'id': act_id})586 mapping={'id': act_id}) 581 587 self.updatePage(cat_name) 582 588 … … 602 608 # issue portal status message 603 609 self.kss_issueMessage(_(u"'${id}' action successfully removed.", 604 mapping={'id': act_id}))610 mapping={'id': act_id})) 605 611 606 612 @kssaction … … 615 621 # if not errors find (or create) category and set action to it 616 622 ksscore = self.getCommandSet('core') 617 kssplone = self.getCommandSet('plone')618 623 if not errors: 619 624 action = self.addAction(cat_name, data) … … 621 626 # update client 622 627 # add one more action to actions list 623 content = self.getActionsList(category=cat_name, tabs=[action,]) 624 ksscore.insertHTMLAsLastChild(ksscore.getHtmlIdSelector('tabslist'), 625 content) 628 content = self.getActionsList(category=cat_name, tabs=[action, ]) 629 ksscore.insertHTMLAsLastChild( 630 ksscore.getHtmlIdSelector('tabslist'), 631 content) 626 632 627 633 # update reorder controls … … 646 652 647 653 message = _(u"'${id}' action successfully added.", 648 mapping={'id': action.id})654 mapping={'id': action.id}) 649 655 msgtype = "info" 650 656 … … 655 661 if errors.has_key('id') or errors.has_key('available_expr'): 656 662 self.kss_toggleCollapsible( 657 658 663 ksscore.getCssSelector('form[name=addaction_form] ' 664 '.headerAdvanced'), collapse='false') 659 665 660 666 message = _(u"Please correct the indicated errors.") … … 678 684 # collapse advanced section 679 685 self.kss_toggleCollapsible( 680 681 collapse='true')686 ksscore.getCssSelector('form[name=addaction_form] .headerAdvanced'), 687 collapse='true') 682 688 683 689 # reset form inputs … … 705 711 # update client 706 712 ksscore = self.getCommandSet("core") 707 content = self.getActionsList(category=cat_name, tabs=[action_info, ])713 content = self.getActionsList(category=cat_name, tabs=[action_info, ]) 708 714 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 709 715 … … 722 728 # update client 723 729 ksscore = self.getCommandSet("core") 724 content = self.getActionsList(category=cat_name, tabs=[action, ])730 content = self.getActionsList(category=cat_name, tabs=[action, ]) 725 731 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 726 732 … … 743 749 html_id = '%s%s%s' % (self.prefix, id, self.sufix) 744 750 ksscore = self.getCommandSet('core') 745 kssplone = self.getCommandSet('plone')746 751 if not errors: 747 752 action = self.updateAction(id, cat_name, data) … … 749 754 # update client 750 755 # replace action item with updated one 751 content = self.getActionsList(category=cat_name, tabs=[action, ])756 content = self.getActionsList(category=cat_name, tabs=[action, ]) 752 757 ksscore.replaceHTML(ksscore.getHtmlIdSelector(html_id), content) 753 758 754 759 message = _(u"'${id}' action successfully updated.", 755 mapping={'id': action.id})760 mapping={'id': action.id}) 756 761 msgtype = "info" 757 762 … … 820 825 def copyAction(self, action): 821 826 """Copy action to dictionary""" 822 action_info = {'description': action.description}827 action_info = {'description': action.description} 823 828 for attr in ACTION_ATTRS: 824 829 action_info[attr] = getattr(action, attr) … … 842 847 chooser.checkName(data['id'], self.context) 843 848 except Exception, e: 844 errors['id'] = self._formatError(e, **{'id': data['id']})849 errors['id'] = self._formatError(e, **{'id': data['id']}) 845 850 846 851 # validate action name … … 968 973 category = self.getActionCategory(cat_name) 969 974 except Exception: 970 raise KSSExplicitError, \ 971 _(u"'${cat_name}' action category does not exist.", 972 mapping={'cat_name': cat_name}) 975 raise KSSExplicitError(u"%s action category does not exist." %\ 976 cat_name) 973 977 974 978 # extract action id from given list item id on client … … 978 982 action = category[action_id] 979 983 except Exception: 980 raise KSSExplicitError, \ 981 _(u"No '${id}' action in '${cat_name}' category.", 982 mapping={'id': action_id, 'cat_name': cat_name}) 984 raise KSSExplicitError("No %s action in %s category." %\ 985 (action_id, cat_name)) 983 986 984 987 return (action_id, category, action) … … 1001 1004 '.error-container' % (id, UI_ATTRS.get(name, name))) 1002 1005 else: 1003 field_selector = ksscore.getCssSelector('form[name=addaction_form] ' 1006 field_selector = ksscore.getCssSelector('form' +\ 1007 '[name=addaction_form] ' 1004 1008 '.field-%s' % UI_ATTRS.get(name, name)) 1005 1009 field_error_selector = ksscore.getCssSelector('form[name=' … … 1023 1027 selector) 1024 1028 if collapsed is not None: 1025 data =command.addParam('collapsed', collapsed)1029 command.addParam('collapsed', collapsed) 1026 1030 if expanded is not None: 1027 data =command.addParam('expanded', expanded)1031 command.addParam('expanded', expanded) 1028 1032 if collapse is not None: 1029 data =command.addParam('collapse', collapse)1033 command.addParam('collapse', collapse) 1030 1034 1031 1035 def kss_resetForm(self, selector): 1032 1036 """KSS Server command to reset form on client""" 1033 command = self.commands.addCommand('plonetabs-resetForm', selector)1034 1037 1035 1038 def kss_blur(self, selector): 1036 1039 """KSS Server command to remove focus from input""" 1037 command =self.commands.addCommand('plonetabs-blur', selector)1040 self.commands.addCommand('plonetabs-blur', selector) 1038 1041 1039 1042 def kss_replaceOrInsert(self, selector, parentSelector, html, … … 1044 1047 command = self.commands.addCommand('plonetabs-replaceOrInsert', 1045 1048 selector) 1046 data =command.addParam('selector', parentSelector)1047 data =command.addHtmlParam('html', html)1048 data =command.addParam('withKssSetup', withKssSetup)1049 command.addParam('selector', parentSelector) 1050 command.addHtmlParam('html', html) 1051 command.addParam('withKssSetup', withKssSetup) 1049 1052 if alternativeHTML: 1050 data =command.addHtmlParam('alternativeHTML', alternativeHTML)1053 command.addHtmlParam('alternativeHTML', alternativeHTML) 1051 1054 if selectorType: 1052 data =command.addParam('selectorType', selectorType)1055 command.addParam('selectorType', selectorType) 1053 1056 if position: 1054 data =command.addParam('position', position)1057 command.addParam('position', position) 1055 1058 if positionSelector: 1056 data =command.addParam('positionSelector', positionSelector)1059 command.addParam('positionSelector', positionSelector) 1057 1060 if positionSelectorType: 1058 data =command.addParam('positionSelectorType',1059 1061 command.addParam('positionSelectorType', 1062 positionSelectorType) 1060 1063 1061 1064 def kss_issueMessage(self, message, msgtype="info"): 1062 1065 """"Issues portal status message and removes it afte 10 seconds""" 1063 1066 ksscore = self.getCommandSet('core') 1064 self.getCommandSet('plone').issuePortalMessage(message, msgtype=msgtype) 1067 self.getCommandSet('plone').issuePortalMessage(message, 1068 msgtype=msgtype) 1065 1069 self.kss_timeout( 1066 1070 ksscore.getHtmlIdSelector('kssPortalMessage'), … … 1071 1075 def kss_timeout(self, selector, **kw): 1072 1076 """KSS Server command to execute plonetabs-timeout client action""" 1073 command =self.commands.addCommand('plonetabs-timeout', selector, **kw)1077 self.commands.addCommand('plonetabs-timeout', selector, **kw) 1074 1078 1075 1079 def renderViewlet(self, manager, name): … … 1117 1121 """Delete action with given id from given category""" 1118 1122 category = self.getActionCategory(cat_name) 1119 category.manage_delObjects(ids=[id, ])1123 category.manage_delObjects(ids=[id, ]) 1120 1124 return True 1121 1125 … … 1125 1129 category = self.getActionCategory(cat_name) 1126 1130 if steps > 0: 1127 category.moveObjectsUp([id, ], steps)1131 category.moveObjectsUp([id, ], steps) 1128 1132 else: 1129 category.moveObjectsDown([id, ], abs(steps))1133 category.moveObjectsDown([id, ], abs(steps)) 1130 1134 return True 1131 1135 return False … … 1170 1174 #ksszope = self.getCommandSet("zope") 1171 1175 #ksszope.refreshViewlet( 1172 1173 1174 1176 #self.getCommandSet("core").getHtmlIdSelector("portal-siteactions"), 1177 #"plone.portalheader", 1178 #"plone.site_actions") 1175 1179 1176 1180 def updateUserPageSection(self): … … 1183 1187 "plone.personal_bar") 1184 1188 1189 1185 1190 class PloneTabsMode(BrowserView): 1186 1191 -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/config.py
r478 r3437 1 1 PROPERTY_SHEET = "tabs_properties" 2 FIELD_NAME 2 FIELD_NAME = "titles" -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/interfaces.py
r815 r3437 1 1 from zope.interface import Interface 2 2 3 3 4 class IPloneTabsProductLayer(Interface): -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/__init__.py
r43 r3437 1 # I'm a package -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/setuphandlers.py
r865 r3437 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/trunk/quintagroup/plonetabs/tests/__init__.py
r756 r3437 1 # -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/base.py
r865 r3437 1 1 try: 2 2 from zope.annotation.interfaces import IAnnotations 3 IAnnotations # pyflakes 3 4 except ImportError: 4 5 from zope.app.annotation.interfaces import IAnnotations 5 6 6 from plone.browserlayer.layer import mark_layer 7 7 8 8 from Testing import ZopeTestCase as ztc 9 9 from Products.Five import zcml 10 from Products.Five import fiveconfigure11 10 from Products.CMFCore.utils import getToolByName 12 from Products.CMFCore.interfaces import IAction, IActionCategory13 11 from Products.CMFCore.ActionInformation import Action, ActionCategory 14 12 from Products.PloneTestCase import PloneTestCase as ptc … … 18 16 19 17 #ztc.installProduct('Zope2Product') 18 20 19 21 20 @onsetup … … 27 26 28 27 setup_package() 28 if ptc.PLONE30: 29 ptc.setupPloneSite(products=["plone.browserlayer"]) 29 30 ptc.setupPloneSite(products=['quintagroup.plonetabs']) 30 31 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/trunk/quintagroup/plonetabs/tests/ecmaunits/__init__.py
r884 r3437 1 # -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/ecmaunits/ecmaview.py
r884 r3437 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/trunk/quintagroup/plonetabs/tests/selenium/__init__.py
r818 r3437 1 # -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/selenium/zopeconfig.py
r818 r3437 4 4 KSSSeleniumTestCase 5 5 6 from plone.app.kss.demo.zopeconfig import PloneSiteLayer, \ 7 LoggedInManagerLayer, LoggedInUserLayer, IResource 6 from plone.app.kss.demo.zopeconfig import LoggedInManagerLayer, IResource 8 7 9 8 … … 14 13 # for your own programs, or otherwise you will need to change 15 14 # 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. 15 # the next kss.demo versions. The plugin class (PloneDemos) 16 # will change in the next major KSS (and possibly Plone) version. 18 17 # This configuration file will be kept up-to-date to these changes. 19 18 # … … 26 25 teardown = KSSSeleniumTestCase('uninstall-tabs.html') 27 26 27 28 28 class PloneTabsSeleniumKssTests(object): 29 29 implements(IResource) … … 33 33 selenium_tests = ( 34 34 KSSSeleniumTestSuite( 35 tests = KSSSeleniumTestDirectory('selenium_tests/run_as_testmanager'), 36 layer = PortalTabsLayer, 37 component = 'quintagroup.plonetabs', 38 application = 'quintagroup.plonetabs', 35 tests=KSSSeleniumTestDirectory('selenium_tests/' +\ 36 'run_as_testmanager'), 37 layer=PortalTabsLayer, 38 component='quintagroup.plonetabs', 39 application='quintagroup.plonetabs', 39 40 ), 40 41 ) -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_controlpanel.py
r917 r3437 6 6 7 7 from Products.CMFCore.utils import getToolByName 8 from Products.CMFCore.ActionInformation import Action , ActionCategory8 from Products.CMFCore.ActionInformation import Action 9 9 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 75 from Products.CMFCore.Expression import getEngine 76 from Products.CMFCore.Expression import Expression 77 73 78 def __init__(self, text): 74 79 self.text = text 75 80 if text.strip(): 76 81 self._v_compiled = getEngine().compile(text) 77 from Products.CMFCore.Expression import Expression 82 78 83 optimized__init__ = Expression.__init__ 79 84 Expression.__init__ = __init__ … … 81 86 # rollback our patch 82 87 Expression.__init__ = optimized__init__ 83 88 84 89 self.assertEquals(len(errors.keys()), 4, 85 90 'validateActionFields method is not working properly.') 86 91 #### pyflakes.scripts.pyflakes ends. 92 87 93 def test_processErrors(self): 88 94 method = self.panel.processErrors 89 errors = {'error': 'error message'}95 errors = {'error': 'error message'} 90 96 self.assertEquals(method(errors), errors, 91 97 'processErrors method is not working properly.') … … 93 99 {'pre_error_post': 'error message'}, 94 100 'processErrors method is not working properly.') 95 101 96 102 def test_parseEditForm(self): 97 103 method = self.panel.parseEditForm … … 110 116 'visible': True}), 111 117 'parseEditForm method is not working properly.') 112 118 113 119 del form['orig_id'] 114 120 self.failUnlessRaises(KeyError, method, form) 115 121 116 122 def test_parseAddForm(self): 117 123 method = self.panel.parseAddForm … … 129 135 'available_expr': 'expr2'}), 130 136 'parseAddForm method is not working properly.') 131 137 132 138 del form['id'] 133 139 self.failUnlessRaises(KeyError, method, form) 134 140 135 141 def test_getActionCategory(self): 136 142 method = self.panel.getActionCategory 137 143 self.purgeActions() 138 144 self.failUnlessRaises(KeyError, method, 'portal_tabs') 139 145 140 146 self.setupActions(self.tool) 141 147 self.assertEquals(method('portal_tabs').id, 'portal_tabs', 142 148 'getActionCategory is not working properly.') 143 149 144 150 def test_getOrCreateCategory(self): 145 151 method = self.panel.getOrCreateCategory … … 147 153 self.assertEquals(method('portal_tabs').id, 'portal_tabs', 148 154 'getOrCreateCategory is not working properly.') 149 155 150 156 def test_setSiteProperties(self): 151 157 self.panel.setSiteProperties(title='Test Title') … … 153 159 self.assertEquals(sp.getProperty('title'), 'Test Title', 154 160 'setSiteProperties method is not working properly.') 155 161 156 162 def test_renderViewlet(self): 157 163 # register test viewlet and it's manager … … 161 167 from zope.publisher.interfaces.browser import IDefaultBrowserLayer 162 168 from zope.publisher.interfaces.browser import IBrowserView 169 163 170 class TestViewlet(ViewletBase): 164 171 def __of__(self, obj): 165 172 return self 173 166 174 def render(self): 167 175 return 'test viewlet' 176 168 177 provideAdapter( 169 178 TestViewlet, … … 176 185 IViewletManager, 177 186 name=u'test_manager') 178 187 179 188 self.assertEquals( 180 189 self.panel.renderViewlet('test_manager', 'test_viewlet'), 181 190 'test viewlet', 182 191 'renderViewlet method is not workig properly') 183 192 184 193 def test_addAction(self): 185 194 self.purgeActions() 186 self.panel.addAction('new_category', {'id': 'id1', 'title':'Test'})195 self.panel.addAction('new_category', {'id': 'id1', 'title': 'Test'}) 187 196 self.failUnless('id1' in self.tool.new_category.objectIds(), 188 197 'addAction method is not workig properly') 189 198 190 199 def test_updateAction(self): 191 200 method = self.panel.updateAction 192 193 self.purgeActions() 194 self.failUnlessRaises(KeyError, method, 'id1', 'cat1', {'id': 'new'})195 201 202 self.purgeActions() 203 self.failUnlessRaises(KeyError, method, 'id1', 'cat1', {'id': 'new'}) 204 196 205 self.setupActions(self.tool) 197 206 # we need to commit transaction because … … 199 208 import transaction 200 209 transaction.savepoint() 201 method('home', 'portal_tabs', {'id': 'new_home'})210 method('home', 'portal_tabs', {'id': 'new_home'}) 202 211 self.failUnless('new_home' in self.tool.portal_tabs.objectIds(), 203 212 'updateAction method is not workig properly') 204 213 205 214 def test_deleteAction(self): 206 215 self.purgeActions() … … 209 218 self.failIf('home' in self.tool.portal_tabs.objectIds(), 210 219 'deleteAction method is not workig properly') 211 220 212 221 def test_moveAction(self): 213 222 self.purgeActions() … … 223 232 class TestControlPanelAPIMethods(PloneTabsTestCase): 224 233 """Test here interface methods of control panel class""" 225 234 226 235 def afterSetUp(self): 227 236 super(TestControlPanelAPIMethods, self).afterSetUp() … … 232 241 self.panel = panel.__of__(self.portal) 233 242 self.tool = getToolByName(self.portal, 'portal_actions') 234 243 235 244 def test_interface(self): 236 245 self.failUnless(IPloneTabsControlPanel.implementedBy(ptp), … … 238 247 self.failUnless(verifyClass(IPloneTabsControlPanel, ptp), 239 248 'PloneTabs control panel does not implement required interface.') 240 249 241 250 def test_getPageTitle(self): 242 251 self.assertEquals(self.panel.getPageTitle(), … … 247 256 mapping={'cat_name': 'notexists'}), 248 257 'getPageTitle method is broken') 249 258 250 259 def test_hasActions(self): 251 260 method = self.panel.hasActions … … 254 263 self.failIf(method(), 255 264 'There should be no portal_tab actions in portal') 256 265 257 266 # setup our own actions 258 267 self.setupActions(self.tool) 259 268 self.failUnless(method(), 260 269 'There should be portal_tab actions in portal') 261 270 262 271 def test_getPortalActions(self): 263 272 method = self.panel.getPortalActions … … 266 275 self.assertEquals(len(method()), 0, 267 276 'There should be no actions in portal_tabs category.') 268 277 269 278 # setup our own actions 270 279 self.setupActions(self.tool) 271 280 self.assertEquals(len(method()), 2, 272 281 'There should be 2 actions in portal_tabs category.') 273 282 274 283 # marginal arguments 275 284 self.assertEquals(len(method('notexistent_category')), 0, 276 285 'There should be no actions for not existed category.') 277 286 278 287 def test_isGeneratedTabs(self): 279 288 method = self.panel.isGeneratedTabs … … 282 291 sp.manage_changeProperties(disable_folder_sections=True) 283 292 self.failIf(method(), 'But folder sections are disabled...') 284 293 285 294 def test_isNotFoldersGenerated(self): 286 295 method = self.panel.isNotFoldersGenerated … … 289 298 sp.manage_changeProperties(disable_nonfolderish_sections=True) 290 299 self.failIf(method(), 'But non folderish sections are disabled...') 291 300 292 301 def test_getActionsList(self): 293 302 method = self.panel.getActionsList … … 299 308 self.failUnless('class="editform"' in method(), 300 309 'There are no actions in actions list template.') 301 310 302 311 def test_getAutoGenereatedSection(self): 303 312 method = self.panel.getAutoGenereatedSection … … 308 317 'There should be form in autogenerated tabs template ' 309 318 'for portal_tabs category.') 310 319 311 320 def test_getGeneratedTabs(self): 312 321 self.panel.getGeneratedTabs() … … 316 325 'Mon, 26 Jul 1996 05:00:00 GMT', 317 326 'Expiration header is not set properly.') 318 327 319 328 def test_getRootTabs(self): 320 329 method = self.panel.getRootTabs … … 323 332 self.assertEquals(len(method()), 0, 324 333 'There should be no root elements for navigation.') 325 334 326 335 # now add some testing content 327 336 self.setupContent(self.portal) 328 337 self.assertEquals(len(method()), 2, 329 338 'There should be 2 elements in portal root for navigation.') 330 339 331 340 # now switch off autogeneration 332 341 sp = getToolByName(self.portal, 'portal_properties').site_properties … … 335 344 'There should be no root elements for navigation when ' 336 345 'tabs autogeneration is switched off.') 337 346 338 347 def test_getCategories(self): 339 348 method = self.panel.getCategories … … 342 351 self.assertEquals(len(method()), 0, 343 352 'There should be no categories in portal_actions tool.') 344 353 345 354 # now setup actions 346 355 self.setupActions(self.tool) 347 356 self.assertEquals(method(), ['portal_tabs', 'new_category'], 348 357 'There should be exactly 2 categories in portal_actions tool.') 349 358 350 359 def test_portal_tabs(self): 351 360 method = self.panel.portal_tabs … … 354 363 self.assertEquals(len(method()), 0, 355 364 'There should be no portal tabs.') 356 365 357 366 # cleanup memoize cache 358 367 # cause actions method of portal context state is caching it's 359 368 # results in request and we have the same request for every call 360 369 self.purgeCache(self.portal.REQUEST) 361 370 362 371 # add actions 363 372 self.setupActions(self.tool) 364 373 self.assertEquals(len(method()), 2, 365 374 'There should be 2 portal tabs.') 366 375 367 376 # add content 368 377 self.setupContent(self.portal) 369 378 self.assertEquals(len(method()), 4, 370 379 'There should be 4 portal tabs.') 371 380 372 381 def test_selected_portal_tab(self): 373 382 self.assertEquals(self.panel.selected_portal_tab(), 'index_html', … … 381 390 class TestControlPanelManageMethods(PloneTabsTestCase): 382 391 """Test here management methods of control panel class""" 383 392 384 393 def afterSetUp(self): 385 394 super(TestControlPanelManageMethods, self).afterSetUp() … … 390 399 self.panel = panel.__of__(self.portal) 391 400 self.tool = getToolByName(self.portal, 'portal_actions') 392 401 393 402 # purge standard set of actions and set our own testing ones 394 403 self.purgeActions() 395 404 self.setupActions(self.tool) 396 405 397 406 def test_manage_setAutogeneration(self): 398 407 self.setupContent(self.portal) … … 405 414 self.failIf(sp.disable_folder_sections) 406 415 self.failUnless(sp.disable_nonfolderish_sections) 407 416 408 417 def test_manage_addAction(self): 409 418 self.purgeActions() … … 418 427 self.failIf(postback, 419 428 'There should be redirect after successfull adding.') 420 429 421 430 def test_manage_editAction(self): 422 431 method = self.panel.manage_editAction … … 432 441 import transaction 433 442 transaction.savepoint() 434 443 435 444 postback = method(form, {}) 436 445 self.failUnless('id_new' in self.tool.portal_tabs.objectIds()) 437 446 self.failIf(postback, 438 447 'There should be redirect after successfull edition.') 439 448 440 449 form['category'] = 'non_existent' 441 450 self.failUnlessRaises(KeyError, method, form, {}) 442 451 443 452 def test_manage_deleteAction(self): 444 453 self.purgeActions() … … 453 462 self.panel.manage_deleteAction(form, {}) 454 463 self.failIf('home' in self.tool.portal_tabs.objectIds()) 455 464 456 465 def test_manage_moveUpAction(self): 457 466 self.purgeActions() … … 467 476 self.assertEquals( 468 477 self.tool.portal_tabs.getObjectPosition('quintagroup'), 0) 469 478 470 479 def test_manage_moveDownAction(self): 471 480 self.purgeActions() … … 487 496 suite.addTest(unittest.makeSuite(TestControlPanelAPIMethods)) 488 497 suite.addTest(unittest.makeSuite(TestControlPanelManageMethods)) 489 498 490 499 # these tests are implemented as Selenium KSS Tests 491 500 # using kss.demo package, and KSS plugins are tested by means of -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_erase.py
r872 r3437 6 6 from Testing import ZopeTestCase as ztc 7 7 8 from zope. component import getSiteManager8 from zope.app.component.hooks import setHooks, setSite 9 9 10 10 from plone.browserlayer.utils import registered_layers … … 14 14 15 15 from quintagroup.plonetabs.tests.base import PloneTabsTestCase 16 16 17 17 18 class TestErase(PloneTabsTestCase): … … 23 24 @classmethod 24 25 def setUp(cls): 26 25 27 app = ztc.app() 26 28 portal = app.plone 29 30 # change the active local site manager 31 setHooks() 32 setSite(portal) 27 33 28 34 # elevate permissions … … 33 39 product_name = 'quintagroup.plonetabs' 34 40 if tool.isProductInstalled(product_name): 35 tool.uninstallProducts([product_name, ])41 tool.uninstallProducts([product_name, ]) 36 42 37 43 # drop elevated perms … … 43 49 def afterSetUp(self): 44 50 self.loginAsPortalOwner() 45 51 46 52 def test_actionIcons(self): 47 53 tool = getToolByName(self.portal, 'portal_actionicons') … … 49 55 self.failIf('plonetabs' in icon_ids, 50 56 'There should be no plonetabs action icon after uninstall.') 51 57 52 58 def test_controlPanel(self): 53 59 tool = getToolByName(self.portal, 'portal_controlpanel') … … 55 61 self.failIf('plonetabs' in action_ids, 56 62 'There should be no plonetabs configlet after after uninstall.') 57 63 58 64 def test_cssRegistry(self): 59 65 tool = getToolByName(self.portal, 'portal_css') … … 62 68 'There should be no ++resource++plonetabs.css stylesheets after' 63 69 ' uninstall.') 64 70 65 71 def test_jsRegistry(self): 66 72 tool = getToolByName(self.portal, 'portal_javascripts') 67 73 68 74 effects = tool.getResource('++resource++pt_effects.js') 69 75 self.failUnless(effects is None, 70 76 'There should be no ++resource++pt_effects.js script after' 71 77 ' uninstall.') 72 78 73 79 dad = tool.getResource('++resource++sa_dragdrop.js') 74 80 self.failUnless(dad is None, … … 86 92 'There should be no ++resource++plonetabsmode.kss sheets after' 87 93 ' uninstall.') 88 94 89 95 def test_propertiesTool(self): 90 96 tool = getToolByName(self.portal, 'portal_properties') … … 99 105 ' after uninstall.' 100 106 ) 101 107 102 108 def test_browserLayer(self): 103 sm = getSiteManager(self.portal)104 109 layers = [o.__name__ for o in registered_layers()] 105 110 self.failIf('IPloneTabsProductLayer' in layers, 106 111 'There should be no quintagroup.plonetabs layer after uninstall.') 112 107 113 108 114 def test_suite(): -
quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_setup.py
r872 r3437 1 1 import unittest 2 3 from zope.component import getSiteManager4 2 5 3 from plone.browserlayer.utils import registered_layers … … 9 7 from quintagroup.plonetabs.tests.base import PloneTabsTestCase 10 8 9 11 10 class TestSetup(PloneTabsTestCase): 12 11 13 12 def afterSetUp(self): 14 13 self.loginAsPortalOwner() 15 14 16 15 def test_actionIcons(self): 17 16 tool = getToolByName(self.portal, 'portal_actionicons') … … 19 18 self.failUnless('plonetabs' in icon_ids, 20 19 'There is no plonetabs action icon in actionicons tool.') 21 20 22 21 def test_controlPanel(self): 23 22 tool = getToolByName(self.portal, 'portal_controlpanel') … … 25 24 self.failUnless('plonetabs' in action_ids, 26 25 'There is no plonetabs action in control panel.') 27 26 28 27 def test_cssRegistry(self): 29 28 tool = getToolByName(self.portal, 'portal_css') … … 31 30 self.failIf(css is None, 32 31 'There is no ++resource++plonetabs.css stylesheets registered.') 33 32 34 33 def test_jsRegistry(self): 35 34 tool = getToolByName(self.portal, 'portal_javascripts') 36 35 37 36 prototype = tool.getResource('++resource++prototype.js') 38 37 self.failIf(prototype is None, … … 40 39 self.failUnless(prototype._data['enabled'], 41 40 '++resource++prototype.js script is disabled.') 42 41 43 42 effects = tool.getResource('++resource++pt_effects.js') 44 43 self.failIf(effects is None, 45 44 'There is no ++resource++pt_effects.js script registered.') 46 45 47 46 dad = tool.getResource('++resource++sa_dragdrop.js') 48 47 self.failIf(dad is None, … … 57 56 self.failIf(kss is None, 58 57 'There is no ++resource++plonetabsmode.kss sheets registered.') 59 58 60 59 def test_propertiesTool(self): 61 60 tool = getToolByName(self.portal, 'portal_properties') … … 68 67 'Site properties was not setup properly' 69 68 ) 70 69 71 70 def test_browserLayerRegistered(self): 72 sm = getSiteManager(self.portal)73 71 layers = [o.__name__ for o in registered_layers()] 74 72 self.failUnless('IPloneTabsProductLayer' in layers, 75 73 'There should be quintagroup.ploentabs browser layer registered.') 74 76 75 77 76 def test_suite(): -
quintagroup.plonetabs/trunk/setup.py
r3382 r3437 4 4 from setuptools import setup, find_packages 5 5 6 version = '0.7 '6 version = '0.7.1-dev' 7 7 8 8 setup(name='quintagroup.plonetabs', … … 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']), … … 31 33 install_requires=[ 32 34 'setuptools', 35 'plone.browserlayer' 33 36 # -*- Extra requirements: -*- 34 37 ],
Note: See TracChangeset
for help on using the changeset viewer.