Changeset 3402 in products


Ignore:
Timestamp:
Apr 2, 2012 1:04:35 PM (12 years ago)
Author:
potar
Message:

Fixing pep8

Location:
quintagroup.plonetabs/branches/tests
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/Extensions/Install.py

    r865 r3402  
    1414) 
    1515 
     16 
    1617def install(self, reinstall=False): 
    1718    """Install a set of products (which themselves may either use Install.py 
    1819    or GenericSetup extension profiles for their configuration) and then 
    1920    install a set of extension profiles. 
    20      
     21 
    2122    One of the extension profiles we install is that of this product. This 
    2223    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 
    2627    We do this because it is not possible to install other products during 
    2728    the execution of an extension profile (i.e. we cannot do this during 
    2829    the importVarious step for this profile). 
    2930    """ 
    30      
     31 
    3132    portal_quickinstaller = getToolByName(self, 'portal_quickinstaller') 
    3233    portal_setup = getToolByName(self, 'portal_setup') 
     
    3940            portal_quickinstaller.installProduct(product) 
    4041            transaction.savepoint() 
    41      
     42 
    4243    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) 
    4446        product_name = extension_id.split(':')[0] 
    4547        portal_quickinstaller.notifyInstalled(product_name) 
    4648        transaction.savepoint() 
    4749 
     50 
    4851def uninstall(self): 
    4952    portal_setup = getToolByName(self, 'portal_setup') 
    5053    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) 
    5256        product_name = extension_id.split(':')[0] 
    5357        transaction.savepoint() 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/Extensions/__init__.py

    r865 r3402  
    1 # 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/__init__.py

    r873 r3402  
    33messageFactory = MessageFactory('quintagroup.plonetabs') 
    44 
     5 
    56def initialize(context): 
    67    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  
    11from zope.interface import Interface, Attribute 
     2 
    23 
    34class IPloneTabsControlPanel(Interface): 
    45    """Configlet for managing portal_actions, quintagroup.plonetabs""" 
    5      
     6 
    67    prefix = Attribute('prefix', 'Prefix to apply on edit forms') 
    78    sufix = Attribute('sufix', 'Sufix to apply on edit forms') 
    8      
     9 
    910    def getPageTitle(category='portal_tabs'): 
    1011        """Return Title for configlet page for given category""" 
    11      
     12 
    1213    def hasActions(category="portal_tabs"): 
    1314        """Whether there are actions in portal_actions with given category""" 
    14      
     15 
    1516    def getPortalActions(category="portal_tabs"): 
    1617        """Return portal actions with given category""" 
    17      
     18 
    1819    def isGeneratedTabs(): 
    1920        """Whether disable_folder_section field is turned off""" 
    20      
     21 
    2122    def isNotFoldersGenerated(): 
    2223        """Whether disable_nonfolderish_sections field is turned off""" 
    23      
     24 
    2425    def getActionsList(category="portal_tabs"): 
    2526        """Return html code for actions list with given category""" 
    26      
     27 
    2728    def getAutoGenereatedSection(cat_name, errors): 
    2829        """Return html code for all autogenerated section""" 
    29      
     30 
    3031    def getGeneratedTabs(): 
    3132        """Return html code for autogenerated tabs""" 
    32      
     33 
    3334    def getRootTabs(): 
    3435        """Return portal root elements""" 
    35      
     36 
    3637    def getCategories(): 
    3738        """Return list of categories contained in portal_actions tool""" 
    38      
     39 
    3940    def portal_tabs(): 
    4041        """See global-sections viewlet""" 
    41      
     42 
    4243    def selected_portal_tab(): 
    4344        """See global-sections viewlet""" 
    44      
     45 
    4546    def test(condition, ifTrue, ifFalse): 
    4647        """Instead of test function in skins page templates""" 
    47      
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/browser/plonetabs.py

    r3401 r3402  
    3838 
    3939cookie_name = 'ploneTabsMode' 
     40 
    4041 
    4142class PloneTabsControlPanel(PloneKSSView): 
     
    148149            IStatusMessage(self.request).addStatusMessage( 
    149150                _(u"'${id}' action successfully added.", 
    150                   mapping={'id':action.id}), type="info") 
     151                  mapping={'id': action.id}), type="info") 
    151152            self.redirect(search="category=%s" % cat_name) 
    152153            return False 
     
    179180        else: 
    180181            errs.update(self.processErrors(errors, 
    181                 sufix='_%s' % id)) # add edit form sufix to error ids 
     182                sufix='_%s' % id))  # add edit form sufix to error ids 
    182183            IStatusMessage(self.request).addStatusMessage( 
    183184                _(u"Please correct the indicated errors."), type="error") 
     
    214215            self.moveAction(id, cat_name, steps=1) 
    215216            IStatusMessage(self.request).addStatusMessage( 
    216                 _(u"'${id}' action moved up.", mapping={'id': id}), type="info") 
     217               _(u"'${id}' action moved up.", mapping={'id': id}), type="info") 
    217218            self.redirect(search="category=%s" % cat_name) 
    218219            return False 
     
    247248        """Redirect to @@plonetabs-controlpanel configlet""" 
    248249        if not url: 
    249             portal_url =  getMultiAdapter((self.context, self.request), 
     250            portal_url = getMultiAdapter((self.context, self.request), 
    250251                name=u"plone_portal_state").portal_url() 
    251252            url = '%s/%s' % (portal_url, "@@plonetabs-controlpanel") 
     
    302303        """See interface""" 
    303304        tool = getToolByName(self.context, "portal_actions") 
    304         return len(tool.listActions(categories=[category,])) > 0 
     305        return len(tool.listActions(categories=[category, ])) > 0 
    305306 
    306307    def getPortalActions(self, category="portal_tabs"): 
     
    322323        site_properties = getToolByName(self.context, 
    323324                                        "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) 
    325327 
    326328    def isNotFoldersGenerated(self): 
     
    364366        query = {} 
    365367        rootPath = getNavigationRoot(context) 
    366         query['path'] = {'query' : rootPath, 'depth' : 1} 
     368        query['path'] = {'query': rootPath, 'depth': 1} 
    367369        query['portal_type'] = utils.typesToList(context) 
    368370 
     
    388390        excludedIds = {} 
    389391        for id in idsNotToList: 
    390             excludedIds[id]=1 
     392            excludedIds[id] = 1 
    391393 
    392394        rawresult = portal_catalog.searchResults(**query) 
     
    396398            if not excludedIds.has_key(item.getId): 
    397399                id, item_url = get_view_url(item) 
    398                 data = {'name'       : utils.pretty_title_or_id(context, item), 
    399                         'id'         : id, 
    400                         'url'        : item_url, 
     400                data = {'name': utils.pretty_title_or_id(context, item), 
     401                        'id': id, 
     402                        'url': item_url, 
    401403                        'description': item.Description, 
    402                         'exclude_from_nav' : item.exclude_from_nav} 
     404                        'exclude_from_nav': item.exclude_from_nav} 
    403405                result.append(data) 
    404406 
     
    428430        actions = getMultiAdapter((self.context, self.request), 
    429431                                   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 
    433435            if 'portal_tabs' in actions: 
    434436                actions_tabs = actions['portal_tabs'] 
    435437            else: 
    436438                actions_tabs = [] 
    437         except ImportError:  
     439        except ImportError: 
    438440            actions_tabs = actions 
    439441 
     
    519521        ksscore = self.getCommandSet("core") 
    520522        content = self.getGeneratedTabs() 
    521         ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), content) 
     523        ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('roottabs'), 
     524                                 content) 
    522525 
    523526        # update global-sections viewlet 
     
    554557                value="invisible") 
    555558            message = _(u"'${id}' object was included into navigation.", 
    556                         mapping={'id':obj_id}) 
     559                        mapping={'id': obj_id}) 
    557560        else: 
    558561            ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 
    559562            message = _(u"'${id}' object was excluded from navigation.", 
    560                         mapping={'id':obj_id}) 
     563                        mapping={'id': obj_id}) 
    561564 
    562565        # update global-sections viewlet 
     
    580583                value="invisible") 
    581584            message = _(u"'${id}' action is now visible.", 
    582                         mapping={'id':act_id}) 
     585                        mapping={'id': act_id}) 
    583586        else: 
    584587            ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 
    585588            message = _(u"'${id}' action is now invisible.", 
    586                         mapping={'id':act_id}) 
     589                        mapping={'id': act_id}) 
    587590        self.updatePage(cat_name) 
    588591 
     
    608611        # issue portal status message 
    609612        self.kss_issueMessage(_(u"'${id}' action successfully removed.", 
    610                                 mapping={'id':act_id})) 
     613                                mapping={'id': act_id})) 
    611614 
    612615    @kssaction 
     
    627630            # update client 
    628631            # 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) 
    632636 
    633637            # update reorder controls 
     
    652656 
    653657            message = _(u"'${id}' action successfully added.", 
    654                         mapping={'id':action.id}) 
     658                        mapping={'id': action.id}) 
    655659            msgtype = "info" 
    656660 
     
    661665            if errors.has_key('id') or errors.has_key('available_expr'): 
    662666                self.kss_toggleCollapsible( 
    663                     ksscore.getCssSelector('form[name=addaction_form] ' 
    664                                            '.headerAdvanced'), collapse='false') 
     667                   ksscore.getCssSelector('form[name=addaction_form] ' 
     668                                          '.headerAdvanced'), collapse='false') 
    665669 
    666670            message = _(u"Please correct the indicated errors.") 
     
    684688        # collapse advanced section 
    685689        self.kss_toggleCollapsible( 
    686             ksscore.getCssSelector('form[name=addaction_form] .headerAdvanced'), 
    687             collapse='true') 
     690           ksscore.getCssSelector('form[name=addaction_form] .headerAdvanced'), 
     691                                  collapse='true') 
    688692 
    689693        # reset form inputs 
     
    711715        # update client 
    712716        ksscore = self.getCommandSet("core") 
    713         content = self.getActionsList(category=cat_name, tabs=[action_info,]) 
     717        content = self.getActionsList(category=cat_name, tabs=[action_info, ]) 
    714718        ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 
    715719 
     
    728732        # update client 
    729733        ksscore = self.getCommandSet("core") 
    730         content = self.getActionsList(category=cat_name, tabs=[action,]) 
     734        content = self.getActionsList(category=cat_name, tabs=[action, ]) 
    731735        ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 
    732736 
     
    755759            # update client 
    756760            # replace action item with updated one 
    757             content = self.getActionsList(category=cat_name, tabs=[action,]) 
     761            content = self.getActionsList(category=cat_name, tabs=[action, ]) 
    758762            ksscore.replaceHTML(ksscore.getHtmlIdSelector(html_id), content) 
    759763 
    760764            message = _(u"'${id}' action successfully updated.", 
    761                         mapping={'id':action.id}) 
     765                        mapping={'id': action.id}) 
    762766            msgtype = "info" 
    763767 
     
    826830    def copyAction(self, action): 
    827831        """Copy action to dictionary""" 
    828         action_info = {'description':action.description} 
     832        action_info = {'description': action.description} 
    829833        for attr in ACTION_ATTRS: 
    830834            action_info[attr] = getattr(action, attr) 
     
    848852            chooser.checkName(data['id'], self.context) 
    849853        except Exception, e: 
    850             errors['id'] = self._formatError(e, **{'id':data['id']}) 
     854            errors['id'] = self._formatError(e, **{'id': data['id']}) 
    851855 
    852856        # validate action name 
     
    10071011                '.error-container' % (id, UI_ATTRS.get(name, name))) 
    10081012        else: 
    1009             field_selector = ksscore.getCssSelector('form[name=addaction_form] ' 
     1013            field_selector = ksscore.getCssSelector('form' +\ 
     1014                '[name=addaction_form] ' 
    10101015                '.field-%s' % UI_ATTRS.get(name, name)) 
    10111016            field_error_selector = ksscore.getCssSelector('form[name=' 
     
    10681073        """"Issues portal status message and removes it afte 10 seconds""" 
    10691074        ksscore = self.getCommandSet('core') 
    1070         self.getCommandSet('plone').issuePortalMessage(message, msgtype=msgtype) 
     1075        self.getCommandSet('plone').issuePortalMessage(message, 
     1076                                                       msgtype=msgtype) 
    10711077        self.kss_timeout( 
    10721078            ksscore.getHtmlIdSelector('kssPortalMessage'), 
     
    11231129        """Delete action with given id from given category""" 
    11241130        category = self.getActionCategory(cat_name) 
    1125         category.manage_delObjects(ids=[id,]) 
     1131        category.manage_delObjects(ids=[id, ]) 
    11261132        return True 
    11271133 
     
    11311137            category = self.getActionCategory(cat_name) 
    11321138            if steps > 0: 
    1133                 category.moveObjectsUp([id,], steps) 
     1139                category.moveObjectsUp([id, ], steps) 
    11341140            else: 
    1135                 category.moveObjectsDown([id,], abs(steps)) 
     1141                category.moveObjectsDown([id, ], abs(steps)) 
    11361142            return True 
    11371143        return False 
     
    11761182        #ksszope = self.getCommandSet("zope") 
    11771183        #ksszope.refreshViewlet( 
    1178             #self.getCommandSet("core").getHtmlIdSelector("portal-siteactions"), 
    1179             #"plone.portalheader", 
    1180             #"plone.site_actions") 
     1184           #self.getCommandSet("core").getHtmlIdSelector("portal-siteactions"), 
     1185           #"plone.portalheader", 
     1186           #"plone.site_actions") 
    11811187 
    11821188    def updateUserPageSection(self): 
     
    11891195            "plone.personal_bar") 
    11901196 
     1197 
    11911198class PloneTabsMode(BrowserView): 
    11921199 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/config.py

    r478 r3402  
    11PROPERTY_SHEET = "tabs_properties" 
    2 FIELD_NAME     = "titles" 
     2FIELD_NAME = "titles" 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/interfaces.py

    r815 r3402  
    11from zope.interface import Interface 
     2 
    23 
    34class 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  
    11from Products.CMFCore.utils import getToolByName 
     2 
    23 
    34def cleanUpControlPanel(portal, out): 
     
    78        out.append('plonetabs configlet unregistered.') 
    89 
     10 
    911def uninstall(context): 
    1012    # Only run step if a flag file is present (e.g. not an extension profile) 
     
    1315    out = [] 
    1416    site = context.getSite() 
    15      
     17 
    1618    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  
    1919#ztc.installProduct('Zope2Product') 
    2020 
     21 
    2122@onsetup 
    2223def setup_package(): 
     
    3132_marker = object() 
    3233 
     34 
    3335class PloneTabsTestCase(ptc.PloneTestCase): 
    3436    """Common test base class""" 
    35      
     37 
    3638    def afterSetUp(self): 
    3739        # due to some reason plone.browserlayer is not marking REQUEST 
    3840        # with installed products layer interfaces 
    39         # so I'm doing it manually here  
     41        # so I'm doing it manually here 
    4042        class DummyEvent(object): 
    4143            def __init__(self, request): 
    4244                self.request = request 
    4345        mark_layer(self.portal, DummyEvent(self.portal.REQUEST)) 
    44      
     46 
    4547    def purgeCache(self, request): 
    4648        annotations = IAnnotations(request) 
     
    4850        if cache is not _marker: 
    4951            del annotations['plone.memoize'] 
    50      
     52 
    5153    def purgeActions(self): 
    5254        for obj in self.tool.objectValues(): 
     
    5658            #elif IActionCategory.providedBy(obj): 
    5759                #obj.manage_delObjects(ids=obj.objectIds()) 
    58      
     60 
    5961    def setupActions(self, parent, kids=PORTAL_ACTIONS): 
    6062        ids = parent.objectIds() 
     
    6870                if child.get('children', {}): 
    6971                    self.setupActions(getattr(parent, id), child['children']) 
    70      
     72 
    7173    def purgeContent(self): 
    7274        ids = [obj.id for obj in self.portal.listFolderContents()] 
    7375        self.portal.manage_delObjects(ids=ids) 
    74      
     76 
    7577    def setupContent(self, parent, kids=PORTAL_CONTENT): 
    7678        ids = parent.objectIds() 
     
    8082            if child.get('children', {}) and id in ids: 
    8183                self.setupContent(getattr(parent, id), child['children']) 
    82      
     84 
    8385    def _createType(self, container, portal_type, id, **kwargs): 
    8486        """Helper method to create content objects""" 
    8587        ttool = getToolByName(container, 'portal_types') 
    86         portal_catalog =  getToolByName(container, 'portal_catalog') 
    87      
     88        portal_catalog = getToolByName(container, 'portal_catalog') 
     89 
    8890        fti = ttool.getTypeInfo(portal_type) 
    8991        fti.constructInstance(container, id, **kwargs) 
    9092        obj = getattr(container.aq_inner.aq_explicit, id) 
    91      
     93 
    9294        # publish and reindex 
    9395        #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  
    22from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile 
    33from kss.core.tests.ecmaview import EcmaView as base 
     4 
    45 
    56def absolute_dir(path): 
     
    78    return os.path.abspath(os.path.join(here, path)) 
    89 
     10 
    911class EcmaView(base): 
    1012    '''quintagroup.plonetabs js test view 
    11      
     13 
    1214    This allows the runner.html to be used on this view. 
    1315 
  • 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  
    1414# for your own programs, or otherwise you will need to change 
    1515# 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. 
    1818# This configuration file will be kept up-to-date to these changes. 
    1919# 
     
    2626    teardown = KSSSeleniumTestCase('uninstall-tabs.html') 
    2727 
     28 
    2829class PloneTabsSeleniumKssTests(object): 
    2930    implements(IResource) 
     
    3334    selenium_tests = ( 
    3435        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', 
    3941        ), 
    4042    ) 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_controlpanel.py

    r917 r3402  
    1010from quintagroup.plonetabs import messageFactory as _ 
    1111from quintagroup.plonetabs.browser.interfaces import IPloneTabsControlPanel 
    12 from quintagroup.plonetabs.browser.plonetabs import PloneTabsControlPanel as ptp 
     12from quintagroup.plonetabs.browser.plonetabs \ 
     13                                      import PloneTabsControlPanel as ptp 
    1314from quintagroup.plonetabs.tests.base import PloneTabsTestCase 
    1415from quintagroup.plonetabs.tests.data import PORTAL_ACTIONS 
    1516 
     17 
    1618class TestControlPanelHelperMethods(PloneTabsTestCase): 
    1719    """Test here configlet helper methods""" 
    18      
    1920    def afterSetUp(self): 
    2021        super(TestControlPanelHelperMethods, self).afterSetUp() 
     
    2526        self.panel = panel.__of__(self.portal) 
    2627        self.tool = getToolByName(self.portal, 'portal_actions') 
    27      
     28 
    2829    def test_redirect(self): 
    2930        response = self.portal.REQUEST.RESPONSE 
    3031        method = self.panel.redirect 
    31         portal_url =  getMultiAdapter((self.portal, self.portal.REQUEST), 
     32        portal_url = getMultiAdapter((self.portal, self.portal.REQUEST), 
    3233                                      name=u"plone_portal_state").portal_url() 
    3334        url = '%s/@@plonetabs-controlpanel' % portal_url 
     
    3536        self.assertEquals(response.headers.get('location', ''), url, 
    3637            'Redirect method is not working properly.') 
    37          
     38 
    3839        # check query string and anchor hash 
    3940        method('http://quintagroup.com', 'q=test', 'hash_code') 
     
    4142            'http://quintagroup.com?q=test#hash_code', 
    4243            'Redirect method is not working properly.') 
    43      
     44 
    4445    def test_fixExpression(self): 
    4546        method = self.panel.fixExpression 
    4647        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') 
    4850        self.assertEquals(method('python:True'), 'python:True') 
    4951        self.assertEquals(method('hello'), 'string:${object_url}/hello') 
    50      
     52 
    5153    def test_copyAction(self): 
    5254        data = PORTAL_ACTIONS[0][1]['children'][0][1] 
     
    5557        self.assertEquals(len(info.keys()), 6) 
    5658        self.assertEquals(info['description'], 'The most important place') 
    57      
     59 
    5860    def test_validateActionFields(self): 
    5961        method = self.panel.validateActionFields 
     
    6365        self.assertEquals(errors, {}, 
    6466            'There should be no errors for valid data.') 
    65          
    66         bad_data = {'id':'', 
     67 
     68        bad_data = {'id': '', 
    6769                    'title': ' ', 
    6870                    'available_expr': 'bad_type:test', 
    6971                    'url_expr': 'bad_type:test'} 
    70          
     72 
    7173        # Revert PloneTestCase's optimization 
    7274        # because this breaks our test 
     
    8183        # rollback our patch 
    8284        Expression.__init__ = optimized__init__ 
    83          
     85 
    8486        self.assertEquals(len(errors.keys()), 4, 
    8587            'validateActionFields method is not working properly.') 
    86      
     88 
    8789    def test_processErrors(self): 
    8890        method = self.panel.processErrors 
    89         errors = {'error':'error message'} 
     91        errors = {'error': 'error message'} 
    9092        self.assertEquals(method(errors), errors, 
    9193            'processErrors method is not working properly.') 
     
    9395            {'pre_error_post': 'error message'}, 
    9496            'processErrors method is not working properly.') 
    95      
     97 
    9698    def test_parseEditForm(self): 
    9799        method = self.panel.parseEditForm 
     
    110112                             'visible': True}), 
    111113            'parseEditForm method is not working properly.') 
    112          
     114 
    113115        del form['orig_id'] 
    114116        self.failUnlessRaises(KeyError, method, form) 
    115      
     117 
    116118    def test_parseAddForm(self): 
    117119        method = self.panel.parseAddForm 
     
    129131                             'available_expr': 'expr2'}), 
    130132            'parseAddForm method is not working properly.') 
    131          
     133 
    132134        del form['id'] 
    133135        self.failUnlessRaises(KeyError, method, form) 
    134      
     136 
    135137    def test_getActionCategory(self): 
    136138        method = self.panel.getActionCategory 
    137139        self.purgeActions() 
    138140        self.failUnlessRaises(KeyError, method, 'portal_tabs') 
    139          
     141 
    140142        self.setupActions(self.tool) 
    141143        self.assertEquals(method('portal_tabs').id, 'portal_tabs', 
    142144            'getActionCategory is not working properly.') 
    143      
     145 
    144146    def test_getOrCreateCategory(self): 
    145147        method = self.panel.getOrCreateCategory 
     
    147149        self.assertEquals(method('portal_tabs').id, 'portal_tabs', 
    148150            'getOrCreateCategory is not working properly.') 
    149      
     151 
    150152    def test_setSiteProperties(self): 
    151153        self.panel.setSiteProperties(title='Test Title') 
     
    153155        self.assertEquals(sp.getProperty('title'), 'Test Title', 
    154156            'setSiteProperties method is not working properly.') 
    155      
     157 
    156158    def test_renderViewlet(self): 
    157159        # register test viewlet and it's manager 
     
    161163        from zope.publisher.interfaces.browser import IDefaultBrowserLayer 
    162164        from zope.publisher.interfaces.browser import IBrowserView 
     165 
    163166        class TestViewlet(ViewletBase): 
    164167            def __of__(self, obj): 
    165168                return self 
     169 
    166170            def render(self): 
    167171                return 'test viewlet' 
     172 
    168173        provideAdapter( 
    169174            TestViewlet, 
     
    176181            IViewletManager, 
    177182            name=u'test_manager') 
    178          
     183 
    179184        self.assertEquals( 
    180185            self.panel.renderViewlet('test_manager', 'test_viewlet'), 
    181186            'test viewlet', 
    182187            'renderViewlet method is not workig properly') 
    183      
     188 
    184189    def test_addAction(self): 
    185190        self.purgeActions() 
    186         self.panel.addAction('new_category', {'id':'id1', 'title':'Test'}) 
     191        self.panel.addAction('new_category', {'id': 'id1', 'title': 'Test'}) 
    187192        self.failUnless('id1' in self.tool.new_category.objectIds(), 
    188193            'addAction method is not workig properly') 
    189      
     194 
    190195    def test_updateAction(self): 
    191196        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 
    196201        self.setupActions(self.tool) 
    197202        # we need to commit transaction because 
     
    199204        import transaction 
    200205        transaction.savepoint() 
    201         method('home', 'portal_tabs', {'id':'new_home'}) 
     206        method('home', 'portal_tabs', {'id': 'new_home'}) 
    202207        self.failUnless('new_home' in self.tool.portal_tabs.objectIds(), 
    203208            'updateAction method is not workig properly') 
    204      
     209 
    205210    def test_deleteAction(self): 
    206211        self.purgeActions() 
     
    209214        self.failIf('home' in self.tool.portal_tabs.objectIds(), 
    210215             'deleteAction method is not workig properly') 
    211      
     216 
    212217    def test_moveAction(self): 
    213218        self.purgeActions() 
     
    223228class TestControlPanelAPIMethods(PloneTabsTestCase): 
    224229    """Test here interface methods of control panel class""" 
    225      
     230 
    226231    def afterSetUp(self): 
    227232        super(TestControlPanelAPIMethods, self).afterSetUp() 
     
    232237        self.panel = panel.__of__(self.portal) 
    233238        self.tool = getToolByName(self.portal, 'portal_actions') 
    234      
     239 
    235240    def test_interface(self): 
    236241        self.failUnless(IPloneTabsControlPanel.implementedBy(ptp), 
     
    238243        self.failUnless(verifyClass(IPloneTabsControlPanel, ptp), 
    239244            'PloneTabs control panel does not implement required interface.') 
    240      
     245 
    241246    def test_getPageTitle(self): 
    242247        self.assertEquals(self.panel.getPageTitle(), 
     
    247252              mapping={'cat_name': 'notexists'}), 
    248253            'getPageTitle method is broken') 
    249      
     254 
    250255    def test_hasActions(self): 
    251256        method = self.panel.hasActions 
     
    254259        self.failIf(method(), 
    255260            'There should be no portal_tab actions in portal') 
    256          
     261 
    257262        # setup our own actions 
    258263        self.setupActions(self.tool) 
    259264        self.failUnless(method(), 
    260265            'There should be portal_tab actions in portal') 
    261      
     266 
    262267    def test_getPortalActions(self): 
    263268        method = self.panel.getPortalActions 
     
    266271        self.assertEquals(len(method()), 0, 
    267272            'There should be no actions in portal_tabs category.') 
    268          
     273 
    269274        # setup our own actions 
    270275        self.setupActions(self.tool) 
    271276        self.assertEquals(len(method()), 2, 
    272277            'There should be 2 actions in portal_tabs category.') 
    273          
     278 
    274279        # marginal arguments 
    275280        self.assertEquals(len(method('notexistent_category')), 0, 
    276281            'There should be no actions for not existed category.') 
    277      
     282 
    278283    def test_isGeneratedTabs(self): 
    279284        method = self.panel.isGeneratedTabs 
     
    282287        sp.manage_changeProperties(disable_folder_sections=True) 
    283288        self.failIf(method(), 'But folder sections are disabled...') 
    284      
     289 
    285290    def test_isNotFoldersGenerated(self): 
    286291        method = self.panel.isNotFoldersGenerated 
     
    289294        sp.manage_changeProperties(disable_nonfolderish_sections=True) 
    290295        self.failIf(method(), 'But non folderish sections are disabled...') 
    291      
     296 
    292297    def test_getActionsList(self): 
    293298        method = self.panel.getActionsList 
     
    299304        self.failUnless('class="editform"' in method(), 
    300305            'There are no actions in actions list template.') 
    301      
     306 
    302307    def test_getAutoGenereatedSection(self): 
    303308        method = self.panel.getAutoGenereatedSection 
     
    308313            'There should be form in autogenerated tabs template ' 
    309314            'for portal_tabs category.') 
    310      
     315 
    311316    def test_getGeneratedTabs(self): 
    312317        self.panel.getGeneratedTabs() 
     
    316321            'Mon, 26 Jul 1996 05:00:00 GMT', 
    317322            'Expiration header is not set properly.') 
    318      
     323 
    319324    def test_getRootTabs(self): 
    320325        method = self.panel.getRootTabs 
     
    323328        self.assertEquals(len(method()), 0, 
    324329            'There should be no root elements for navigation.') 
    325          
     330 
    326331        # now add some testing content 
    327332        self.setupContent(self.portal) 
    328333        self.assertEquals(len(method()), 2, 
    329334            'There should be 2 elements in portal root for navigation.') 
    330          
     335 
    331336        # now switch off autogeneration 
    332337        sp = getToolByName(self.portal, 'portal_properties').site_properties 
     
    335340            'There should be no root elements for navigation when ' 
    336341            'tabs autogeneration is switched off.') 
    337      
     342 
    338343    def test_getCategories(self): 
    339344        method = self.panel.getCategories 
     
    342347        self.assertEquals(len(method()), 0, 
    343348            'There should be no categories in portal_actions tool.') 
    344          
     349 
    345350        # now setup actions 
    346351        self.setupActions(self.tool) 
    347352        self.assertEquals(method(), ['portal_tabs', 'new_category'], 
    348353            'There should be exactly 2 categories in portal_actions tool.') 
    349      
     354 
    350355    def test_portal_tabs(self): 
    351356        method = self.panel.portal_tabs 
     
    354359        self.assertEquals(len(method()), 0, 
    355360            'There should be no portal tabs.') 
    356          
     361 
    357362        # cleanup memoize cache 
    358363        # cause actions method of portal context state is caching it's 
    359364        # results in request and we have the same request for every call 
    360365        self.purgeCache(self.portal.REQUEST) 
    361          
     366 
    362367        # add actions 
    363368        self.setupActions(self.tool) 
    364369        self.assertEquals(len(method()), 2, 
    365370            'There should be 2 portal tabs.') 
    366          
     371 
    367372        # add content 
    368373        self.setupContent(self.portal) 
    369374        self.assertEquals(len(method()), 4, 
    370375            'There should be 4 portal tabs.') 
    371      
     376 
    372377    def test_selected_portal_tab(self): 
    373378        self.assertEquals(self.panel.selected_portal_tab(), 'index_html', 
     
    381386class TestControlPanelManageMethods(PloneTabsTestCase): 
    382387    """Test here management methods of control panel class""" 
    383      
     388 
    384389    def afterSetUp(self): 
    385390        super(TestControlPanelManageMethods, self).afterSetUp() 
     
    390395        self.panel = panel.__of__(self.portal) 
    391396        self.tool = getToolByName(self.portal, 'portal_actions') 
    392          
     397 
    393398        # purge standard set of actions and set our own testing ones 
    394399        self.purgeActions() 
    395400        self.setupActions(self.tool) 
    396      
     401 
    397402    def test_manage_setAutogeneration(self): 
    398403        self.setupContent(self.portal) 
     
    405410        self.failIf(sp.disable_folder_sections) 
    406411        self.failUnless(sp.disable_nonfolderish_sections) 
    407      
     412 
    408413    def test_manage_addAction(self): 
    409414        self.purgeActions() 
     
    418423        self.failIf(postback, 
    419424            'There should be redirect after successfull adding.') 
    420      
     425 
    421426    def test_manage_editAction(self): 
    422427        method = self.panel.manage_editAction 
     
    432437        import transaction 
    433438        transaction.savepoint() 
    434          
     439 
    435440        postback = method(form, {}) 
    436441        self.failUnless('id_new' in self.tool.portal_tabs.objectIds()) 
    437442        self.failIf(postback, 
    438443            'There should be redirect after successfull edition.') 
    439          
     444 
    440445        form['category'] = 'non_existent' 
    441446        self.failUnlessRaises(KeyError, method, form, {}) 
    442      
     447 
    443448    def test_manage_deleteAction(self): 
    444449        self.purgeActions() 
     
    453458        self.panel.manage_deleteAction(form, {}) 
    454459        self.failIf('home' in self.tool.portal_tabs.objectIds()) 
    455      
     460 
    456461    def test_manage_moveUpAction(self): 
    457462        self.purgeActions() 
     
    467472        self.assertEquals( 
    468473            self.tool.portal_tabs.getObjectPosition('quintagroup'), 0) 
    469      
     474 
    470475    def test_manage_moveDownAction(self): 
    471476        self.purgeActions() 
     
    487492    suite.addTest(unittest.makeSuite(TestControlPanelAPIMethods)) 
    488493    suite.addTest(unittest.makeSuite(TestControlPanelManageMethods)) 
    489      
     494 
    490495    # these tests are implemented as Selenium KSS Tests 
    491496    # using kss.demo package, and KSS plugins are tested by means of 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_erase.py

    r3395 r3402  
    1515 
    1616from quintagroup.plonetabs.tests.base import PloneTabsTestCase 
     17 
    1718 
    1819class TestErase(PloneTabsTestCase): 
     
    3940            product_name = 'quintagroup.plonetabs' 
    4041            if tool.isProductInstalled(product_name): 
    41                 tool.uninstallProducts([product_name,]) 
     42                tool.uninstallProducts([product_name, ]) 
    4243 
    4344            # drop elevated perms 
     
    4950    def afterSetUp(self): 
    5051        self.loginAsPortalOwner() 
    51      
     52 
    5253    def test_actionIcons(self): 
    5354        tool = getToolByName(self.portal, 'portal_actionicons') 
     
    5556        self.failIf('plonetabs' in icon_ids, 
    5657            'There should be no plonetabs action icon after uninstall.') 
    57      
     58 
    5859    def test_controlPanel(self): 
    5960        tool = getToolByName(self.portal, 'portal_controlpanel') 
     
    6162        self.failIf('plonetabs' in action_ids, 
    6263            'There should be no plonetabs configlet after after uninstall.') 
    63      
     64 
    6465    def test_cssRegistry(self): 
    6566        tool = getToolByName(self.portal, 'portal_css') 
     
    6869            'There should be no ++resource++plonetabs.css stylesheets after' 
    6970            ' uninstall.') 
    70      
     71 
    7172    def test_jsRegistry(self): 
    7273        tool = getToolByName(self.portal, 'portal_javascripts') 
    73          
     74 
    7475        effects = tool.getResource('++resource++pt_effects.js') 
    7576        self.failUnless(effects is None, 
    7677            'There should be no ++resource++pt_effects.js script after' 
    7778            ' uninstall.') 
    78          
     79 
    7980        dad = tool.getResource('++resource++sa_dragdrop.js') 
    8081        self.failUnless(dad is None, 
     
    9293            'There should be no ++resource++plonetabsmode.kss sheets after' 
    9394            ' uninstall.') 
    94      
     95 
    9596    def test_propertiesTool(self): 
    9697        tool = getToolByName(self.portal, 'portal_properties') 
     
    105106            ' after uninstall.' 
    106107        ) 
    107      
     108 
    108109    def test_browserLayer(self): 
    109110        sm = getSiteManager(self.portal) 
     
    112113            'There should be no quintagroup.plonetabs layer after uninstall.') 
    113114 
     115 
    114116def test_suite(): 
    115117    suite = unittest.TestSuite() 
  • quintagroup.plonetabs/branches/tests/quintagroup/plonetabs/tests/test_setup.py

    r872 r3402  
    99from quintagroup.plonetabs.tests.base import PloneTabsTestCase 
    1010 
     11 
    1112class TestSetup(PloneTabsTestCase): 
    12      
     13 
    1314    def afterSetUp(self): 
    1415        self.loginAsPortalOwner() 
    15      
     16 
    1617    def test_actionIcons(self): 
    1718        tool = getToolByName(self.portal, 'portal_actionicons') 
     
    1920        self.failUnless('plonetabs' in icon_ids, 
    2021            'There is no plonetabs action icon in actionicons tool.') 
    21      
     22 
    2223    def test_controlPanel(self): 
    2324        tool = getToolByName(self.portal, 'portal_controlpanel') 
     
    2526        self.failUnless('plonetabs' in action_ids, 
    2627            'There is no plonetabs action in control panel.') 
    27      
     28 
    2829    def test_cssRegistry(self): 
    2930        tool = getToolByName(self.portal, 'portal_css') 
     
    3132        self.failIf(css is None, 
    3233            'There is no ++resource++plonetabs.css stylesheets registered.') 
    33      
     34 
    3435    def test_jsRegistry(self): 
    3536        tool = getToolByName(self.portal, 'portal_javascripts') 
    36          
     37 
    3738        prototype = tool.getResource('++resource++prototype.js') 
    3839        self.failIf(prototype is None, 
     
    4041        self.failUnless(prototype._data['enabled'], 
    4142            '++resource++prototype.js script is disabled.') 
    42          
     43 
    4344        effects = tool.getResource('++resource++pt_effects.js') 
    4445        self.failIf(effects is None, 
    4546            'There is no ++resource++pt_effects.js script registered.') 
    46          
     47 
    4748        dad = tool.getResource('++resource++sa_dragdrop.js') 
    4849        self.failIf(dad is None, 
     
    5758        self.failIf(kss is None, 
    5859            'There is no ++resource++plonetabsmode.kss sheets registered.') 
    59      
     60 
    6061    def test_propertiesTool(self): 
    6162        tool = getToolByName(self.portal, 'portal_properties') 
     
    6869            'Site properties was not setup properly' 
    6970        ) 
    70      
     71 
    7172    def test_browserLayerRegistered(self): 
    7273        sm = getSiteManager(self.portal) 
     
    7576            'There should be quintagroup.ploentabs browser layer registered.') 
    7677 
     78 
    7779def test_suite(): 
    7880    suite = unittest.TestSuite() 
  • quintagroup.plonetabs/branches/tests/setup.py

    r3401 r3402  
    1212                       open(os.path.join("docs", "HISTORY.txt")).read(), 
    1313 
    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 
    1516      classifiers=[ 
    1617        "Framework :: Plone", 
     
    2324      author='"Quintagroup": http://quintagroup.com/', 
    2425      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', 
    2628      license='GPL', 
    2729      packages=find_packages(exclude=['ez_setup']), 
Note: See TracChangeset for help on using the changeset viewer.