Changeset 3134 in products for quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testExposeDCMetaTags.py
- Timestamp:
- Apr 18, 2011 2:32:21 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/tests/testExposeDCMetaTags.py
r2139 r3134 3 3 from base import * 4 4 5 METATAG = '.*(<meta\s+(?:(?:name="%s"\s*)|(?:content="(?P<tagcontent>.*?)"\s*)){2}/>)' 5 METATAG = '.*(<meta\s+(?:(?:name="%s"\s*)|(?:content="(?P<tagcontent>.' \ 6 '*?)"\s*)){2}/>)' 7 6 8 7 9 class TestExposeDCMetaTags(FunctionalTestCase): … … 9 11 def afterSetUp(self): 10 12 self.sp = self.portal.portal_properties.site_properties 11 self.basic_auth = ':'.join((portal_owner, default_password))13 self.basic_auth = ':'.join((portal_owner, default_password)) 12 14 self.loginAsPortalOwner() 13 15 # Preparation for functional testing … … 16 18 17 19 def test_propertyOff(self): 18 self.sp.manage_changeProperties(exposeDCMetaTags = False) 19 self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 20 m1 = re.match(METATAG % "DC.format", self.html, re.S|re.M) 21 m2 = re.match(METATAG % "DC.distribution", self.html, re.S|re.M) 22 self.assert_(not (m1 or m2), 'DC meta tags avaliable when exposeDCMetaTags=False') 20 self.sp.manage_changeProperties(exposeDCMetaTags=False) 21 self.html = str(self.publish(self.portal.id + '/my_doc', 22 self.basic_auth)) 23 m1 = re.match(METATAG % "DC.format", self.html, re.S | re.M) 24 m2 = re.match(METATAG % "DC.distribution", self.html, re.S | re.M) 25 self.assert_(not (m1 or m2), 'DC meta tags avaliable when ' \ 26 'exposeDCMetaTags=False') 23 27 24 28 def test_propertyOn(self): 25 self.sp.manage_changeProperties(exposeDCMetaTags = True) 26 self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 27 m1 = re.match(METATAG % "DC.format", self.html, re.S|re.M) 28 m2 = re.match(METATAG % "DC.type", self.html, re.S|re.M) 29 self.assert_(m1 and m2, 'DC meta tags not avaliable when createManager=True') 29 self.sp.manage_changeProperties(exposeDCMetaTags=True) 30 self.html = str(self.publish(self.portal.id + '/my_doc', 31 self.basic_auth)) 32 m1 = re.match(METATAG % "DC.format", self.html, re.S | re.M) 33 m2 = re.match(METATAG % "DC.type", self.html, re.S | re.M) 34 self.assert_(m1 and m2, 'DC meta tags not avaliable when ' \ 35 'createManager=True') 30 36 31 37 def test_descriptionInPropertyOff(self): 32 self.sp.manage_changeProperties(exposeDCMetaTags =False)38 self.sp.manage_changeProperties(exposeDCMetaTags=False) 33 39 self.my_doc.setDescription("My document description") 34 self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 35 m = re.match(METATAG % "description", self.html, re.S|re.M) 36 self.assert_(m, 'No "description" meta tag when expose DC meta tags is Off') 40 self.html = str(self.publish(self.portal.id + '/my_doc', 41 self.basic_auth)) 42 m = re.match(METATAG % "description", self.html, re.S | re.M) 43 self.assert_(m, 'No "description" meta tag when expose DC meta tags ' \ 44 'is Off') 37 45 38 46 def test_descriptionInPropertyOn(self): 39 self.sp.manage_changeProperties(exposeDCMetaTags =True)47 self.sp.manage_changeProperties(exposeDCMetaTags=True) 40 48 self.my_doc.setDescription("My document description") 41 self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 42 m = re.match(METATAG % "description", self.html, re.S|re.M) 43 self.assert_(m, 'No "description" meta tag when expose DC meta tags is On') 49 self.html = str(self.publish(self.portal.id + '/my_doc', 50 self.basic_auth)) 51 m = re.match(METATAG % "description", self.html, re.S | re.M) 52 self.assert_(m, 'No "description" meta tag when expose DC meta tags ' \ 53 'is On') 44 54 45 55 def test_dateValidRange(self): 46 self.sp.manage_changeProperties(exposeDCMetaTags =True)47 EFFDSTR, EXPDSTR = 56 self.sp.manage_changeProperties(exposeDCMetaTags=True) 57 EFFDSTR, EXPDSTR = "2009/12/23", "2010/03/10" 48 58 self.my_doc.setExpirationDate(EXPDSTR) 49 59 self.my_doc.setEffectiveDate(EFFDSTR) 50 self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 51 m = re.match(METATAG % "DC.date.valid_range", self.html, re.S|re.M) 60 self.html = str(self.publish(self.portal.id + '/my_doc', 61 self.basic_auth)) 62 m = re.match(METATAG % "DC.date.valid_range", self.html, re.S | re.M) 52 63 content = m and m.group("tagcontent") 53 64 fact = content and map(DateTime, content.split("-")) 54 65 expect = map(DateTime, [EFFDSTR, EXPDSTR]) 55 self.assert_( fact == expect, '"DC.date.valid_range" meta tags content="%s", ' \ 56 'but "%s" must be' % ( fact, expect )) 66 self.assert_(fact == expect, '"DC.date.valid_range" meta tags ' \ 67 'content="%s", but "%s" must be' % (fact, expect)) 68 57 69 58 70 def test_suite():
Note: See TracChangeset
for help on using the changeset viewer.