Changeset 101

Show
Ignore:
Timestamp:
12/23/05 07:35:27
Author:
crchemist
Message:

Added tests for exposeDCMetatags property

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qSEOptimizer/trunk/skins/qSEOptimizer/prefs_seo_setup.cpt.metadata

    r100 r101  
    1111 
    1212[actions] 
    13 action.success=traverse_to:string:prefs_seo_manageActions 
     13action.success=traverse_to:string:prefs_seo_configActions 
    1414action.failure=traverse_to:string:prefs_seo_setup 
  • qSEOptimizer/trunk/tests/testQSEOptimizer.py

    r100 r101  
    1111from Products.CMFQuickInstallerTool.InstalledProduct import InstalledProduct 
    1212from Products.CMFCore.CMFCorePermissions import ManagePortal 
     13from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager 
    1314import re 
    1415 
     
    152153        self.assert_(m, 'Comments not set in') 
    153154 
    154  
    155 TESTS = [TestInstallation, TestResponse] 
     155class TestExposeDCMetaTags(PloneTestCase.FunctionalTestCase): 
     156 
     157    def afterSetUp(self): 
     158        self.qi = self.portal.portal_quickinstaller 
     159        self.sp = self.portal.portal_properties.site_properties 
     160        self.qi.installProduct(PRODUCT) 
     161        self.portal.changeSkin('Plone Default') 
     162 
     163        self.basic_auth = 'portal_manager:secret' 
     164        uf = self.app.acl_users 
     165        uf.userFolderAddUser('portal_manager', 'secret', ['Manager'], []) 
     166        user = uf.getUserById('portal_manager') 
     167        if not hasattr(user, 'aq_base'): 
     168            user = user.__of__(uf) 
     169        newSecurityManager(None, user) 
     170 
     171        '''Preparation for functional testing''' 
     172        self.my_doc = self.portal.invokeFactory('Document', id='my_doc') 
     173        self.my_doc = self.portal['my_doc'] 
     174 
     175    def test_exposeDCMetaTags_in_configletOff(self): 
     176        self.publish(self.portal.id+'/prefs_seo_manageActions', self.basic_auth) 
     177        self.assertEqual(self.sp.exposeDCMetaTags, False) 
     178 
     179    def test_exposeDCMetaTags_in_configletOn(self): 
     180        path = self.portal.id+'/prefs_seo_configActions?exposeDCMetaTags=on' 
     181        self.publish(path, self.basic_auth) 
     182        self.assert_(self.sp.exposeDCMetaTags) 
     183 
     184    def test_exposeDCMetaTagsPropertyOff(self): 
     185        self.sp.manage_changeProperties(exposeDCMetaTags = False) 
     186 
     187        self.my_doc.qseo_properties_edit() 
     188        self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 
     189 
     190        m = re.match('.*<meta content=".*?" name="DC.format" />', self.html, re.S|re.M) or re.match('.*<meta content=".*?" name="DC.distribution" />', self.html, re.S|re.M) 
     191        self.assert_(not m, 'DC meta tags avaliable when exposeDCMetaTags=False') 
     192 
     193    def test_exposeDCMetaTagsPropertyOn(self): 
     194        self.sp.manage_changeProperties(exposeDCMetaTags = True) 
     195 
     196        self.my_doc.qseo_properties_edit() 
     197        self.html = str(self.publish(self.portal.id+'/my_doc', self.basic_auth)) 
     198 
     199        m = re.match('.*<meta content=".*?" name="DC.format" />', self.html, re.S|re.M) and re.match('.*<meta content=".*?" name="DC.distribution" />', self.html, re.S|re.M) 
     200 
     201        self.assert_(m, 'DC meta tags not avaliable when createManager=True') 
     202 
     203TESTS = [TestInstallation, TestResponse, TestExposeDCMetaTags] 
    156204 
    157205def test_suite(): 
     
    160208    suite.addTest(makeSuite(TestInstallation)) 
    161209    suite.addTest(makeSuite(TestResponse)) 
     210    suite.addTest(makeSuite(TestExposeDCMetaTags)) 
    162211    return suite 
    163212