Ignore:
Timestamp:
Apr 18, 2011 2:32:21 PM (13 years ago)
Author:
zidane
Message:

fixes pep8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testContextForm.py

    r3012 r3134  
    3535METATAG = '.*(<meta\s+(?:(?:name="%s"\s*)|(?:content="%s"\s*)){2}/>)' 
    3636 
     37 
    3738class TestContextForm(FunctionalTestCase): 
    3839 
     
    4243        self.wf = self.portal.portal_workflow 
    4344 
    44         self.basic_auth = ':'.join((portal_owner,default_password)) 
     45        self.basic_auth = ':'.join((portal_owner, default_password)) 
    4546        self.loginAsPortalOwner() 
    4647 
     
    5152        self.abs_path = "/%s" % my_doc.absolute_url(1) 
    5253        # prepare seo context form data 
    53         self.sp.manage_changeProperties( 
    54             default_custom_metatags = 'metatag1|global_metatag1value\n' \ 
    55                                       'metatag4|global_metatag4value') 
     54        self.sp.manage_changeProperties(default_custom_metatags='metatag1|' \ 
     55                                        'global_metatag1value\nmetatag4|' \ 
     56                                        'global_metatag4value') 
    5657        st = '' 
    5758        for d in CUSTOM_METATAGS: 
    5859            st += '&seo_custommetatags.meta_name:records=%s' % d['meta_name'] 
    59             st += '&seo_custommetatags.meta_content:records=%s' % d['meta_content'] 
     60            st += '&seo_custommetatags.meta_content:records=%s' \ 
     61                  % d['meta_content'] 
    6062        # update seo properties for the test document and publish it 
    61         self.publish(path=self.abs_path+'/@@seo-context-properties', 
     63        self.publish(path=self.abs_path + '/@@seo-context-properties', 
    6264                     basic=self.basic_auth, request_method='POST', 
    63                      stdin=StringIO(urllib.urlencode(FORM)+st)) 
     65                     stdin=StringIO(urllib.urlencode(FORM) + st)) 
    6466        self.wf.doActionFor(my_doc, 'publish') 
    6567        # get html view of test document 
    6668        self.html = self.publish(self.abs_path, self.basic_auth).getBody() 
    6769 
    68  
    6970    def testTitle(self): 
    70         m = re.match('.*<title>\\s*hello world\\s*</title>', self.html, re.S|re.M) 
     71        m = re.match('.*<title>\\s*hello world\\s*</title>', self.html, 
     72                     re.S | re.M) 
    7173        self.assert_(m, 'Title not set in') 
    7274 
    7375    def testTitleDuplication(self): 
    74         """If we are not overriding page title and current page title equals title of the plone site 
    75         then there should be no concatenation of both titles. Only one should be displayed. 
     76        """If we are not overriding page title and current page title equals 
     77           title of the plone site then there should be no concatenation of 
     78           both titles. Only one should be displayed. 
    7679        """ 
    7780        # setup page with title equal to plone site's title 
     
    8083        my_doc2 = self.portal['my_doc2'] 
    8184        self.wf.doActionFor(my_doc2, 'publish') 
    82         html2 = self.publish('/'+my_doc2.absolute_url(1), self.basic_auth).getBody() 
     85        html2 = self.publish('/' + my_doc2.absolute_url(1), 
     86                             self.basic_auth).getBody() 
    8387 
    84         m = re.match('.*<title>\\s*%s\\s*</title>' % self.portal.Title(), html2, re.S|re.M) 
    85         self.assert_(m, 'Title is not set correctly, perhaps it is duplicated with plone site title') 
     88        m = re.match('.*<title>\\s*%s\\s*</title>' % self.portal.Title(), 
     89                     html2, re.S | re.M) 
     90        self.assert_(m, 'Title is not set correctly, perhaps it is ' \ 
     91                     'duplicated with plone site title') 
    8692 
    8793    def testDescription(self): 
    88         m = re.match(METATAG % ("description", FORM['seo_description']), self.html, re.S|re.M) 
     94        m = re.match(METATAG % ("description", FORM['seo_description']), 
     95                     self.html, re.S | re.M) 
    8996        self.assert_(m, 'Description not set in') 
    9097 
    9198    def testRobots(self): 
    92         m = re.match(METATAG % ("robots", FORM['seo_robots']), self.html, re.S|re.M) 
     99        m = re.match(METATAG % ("robots", FORM['seo_robots']), self.html, 
     100                     re.S | re.M) 
    93101        self.assert_(m, 'Robots not set in') 
    94102 
    95103    def testDistribution(self): 
    96         m = re.match(METATAG % ("distribution", FORM['seo_distribution']), self.html, re.S|re.M) 
     104        m = re.match(METATAG % ("distribution", FORM['seo_distribution']), 
     105                     self.html, re.S | re.M) 
    97106        self.assert_(m, 'Distribution not set in') 
    98107 
    99108    def testHTMLComments(self): 
    100         m = re.match('.*<!--\\s*no comments\\s*-->', self.html, re.S|re.M) 
     109        m = re.match('.*<!--\\s*no comments\\s*-->', self.html, re.S | re.M) 
    101110        self.assert_(m, 'Comments not set in') 
    102111 
    103112    def testTagsOrder(self): 
    104113        def is_match(html, mtorder): 
    105             return re.search('.*'.join(['<meta.*name="%s".*/>' %t \ 
    106                                         for t in mtorder]), html, re.S|re.M) 
     114            return re.search('.*'.join(['<meta.*name="%s".*/>' % t \ 
     115                                        for t in mtorder]), html, re.S | re.M) 
    107116 
    108         metatags_order = [t for t in self.sp.getProperty('metatags_order') if t in VIEW_METATAGS] 
    109         self.assert_(is_match(self.html, metatags_order), "Meta tags order not supported.") 
     117        metatags_order = [t for t in self.sp.getProperty('metatags_order') \ 
     118                            if t in VIEW_METATAGS] 
     119        self.assert_(is_match(self.html, metatags_order), 
     120                     "Meta tags order not supported.") 
    110121 
    111122        metatags_order.reverse() 
    112         self.assertFalse(is_match(self.html, metatags_order), "Meta tags order not supported.") 
     123        self.assertFalse(is_match(self.html, metatags_order), 
     124                         "Meta tags order not supported.") 
    113125 
    114         self.sp.manage_changeProperties(metatags_order = metatags_order) 
    115         self.assertFalse(is_match(self.html, metatags_order), "Meta tags order not supported.") 
     126        self.sp.manage_changeProperties(metatags_order=metatags_order) 
     127        self.assertFalse(is_match(self.html, metatags_order), 
     128                         "Meta tags order not supported.") 
    116129 
    117130        html = self.publish(self.abs_path, self.basic_auth).getBody() 
    118         self.assert_(is_match(html, metatags_order), "Meta tags order not supported.") 
    119  
     131        self.assert_(is_match(html, metatags_order), 
     132                     "Meta tags order not supported.") 
    120133 
    121134    def testCustomMetaTags(self): 
    122135        for tag in CUSTOM_METATAGS: 
    123136            m = re.match(METATAG % (tag['meta_name'], tag['meta_content']), 
    124                          self.html, re.S|re.M) 
     137                         self.html, re.S | re.M) 
    125138            if tag['meta_content']: 
    126                 self.assert_(m, "Custom meta tag %s not applied." % tag['meta_name']) 
     139                self.assert_(m, "Custom meta tag %s not applied." \ 
     140                             % tag['meta_name']) 
    127141            else: 
    128                 self.assert_(not m, "Meta tag %s has no content, but is present:" \ 
    129                                  " in the page." % tag['meta_name']) 
     142                self.assert_(not m, "Meta tag %s has no content, but is " \ 
     143                             "present: in the page." % tag['meta_name']) 
    130144 
    131         m = re.match(METATAG % ("metatag4", "global_metatag4value"), self.html, re.S|re.M) 
     145        m = re.match(METATAG % ("metatag4", "global_metatag4value"), self.html, 
     146                     re.S | re.M) 
    132147        self.assert_(m, "Global custom meta tag %s not applied." % 'metatag4') 
    133148 
    134149    def testDeleteCustomMetaTags(self): 
    135         self.sp.manage_changeProperties( 
    136             default_custom_metatags = 'metatag1|global_metatag1value') 
     150        self.sp.manage_changeProperties(default_custom_metatags='metatag1|' \ 
     151                                        'global_metatag1value') 
    137152        form_data = {'seo_custommetatags': CUSTOM_METATAGS, 
    138153                     'seo_custommetatags_override:int': 0, 
     
    143158        getUtility(IRAMCache).invalidateAll() 
    144159 
    145         self.publish(path=self.abs_path+'/@@seo-context-properties', 
     160        self.publish(path=self.abs_path + '/@@seo-context-properties', 
    146161                     basic=self.basic_auth, request_method='POST', 
    147162                     stdin=StringIO(urllib.urlencode(form_data))) 
    148163        html = self.publish(self.abs_path, self.basic_auth).getBody() 
    149164 
    150         m = re.match(METATAG % ("metatag4", "global_metatag4value"), html, re.S|re.M) 
    151         self.assert_(not m, "Global custom meta tag %s is prosent in the page." % 'metatag4') 
     165        m = re.match(METATAG % ("metatag4", "global_metatag4value"), html, 
     166                     re.S | re.M) 
     167        self.assert_(not m, "Global custom meta tag %s is prosent in the " \ 
     168                     "page." % 'metatag4') 
    152169 
    153         m = re.match(METATAG % ("metatag1", "global_metatag1value"), html, re.S|re.M) 
     170        m = re.match(METATAG % ("metatag1", "global_metatag1value"), html, 
     171                     re.S | re.M) 
    154172        self.assert_(m, "Global custom meta tag %s not applied." % 'metatag1') 
     173 
    155174 
    156175def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.