Changeset 985

Show
Ignore:
Timestamp:
10/01/07 08:20:27
Author:
crchemist
Message:

Fix tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qSEOptimizer/branches/additional-keywords/__init__.py

    r983 r985  
    77 
    88from Products.qSEOptimizer import config 
    9 from Products.qSEOptimizer.interfaces import IKeywords 
     9 
     10try: 
     11    from Products.qSEOptimizer.interfaces import IKeywords 
     12    zope_interface_available = True 
     13except ImportError: 
     14    zope_interface_available = False 
    1015 
    1116allow_module('Products.qSEOptimizer.util') 
     
    6267 
    6368        # Set the additional matching keywords, if any 
    64         adapter = IKeywords(context, None) 
    65         if adapter is not None: 
    66             keywords = adapter.listKeywords() 
    67             if keywords: 
    68                 metaTags['keywords'] = keywords 
     69        if zope_interface_available: 
     70            adapter = IKeywords(context, None) 
     71            if adapter is not None: 
     72                keywords = adapter.listKeywords() 
     73                if keywords: 
     74                    metaTags['keywords'] = keywords 
    6975 
    7076        return metaTags 
  • qSEOptimizer/branches/additional-keywords/tests/testQSEOptimizer.py

    r982 r985  
    4141PloneTestCase.setupPloneSite() 
    4242 
    43  
     43""" 
    4444class TestBeforeInstall(PloneTestCase.FunctionalTestCase): 
    4545 
     
    5555        response = self.publish(self.portal_path, self.basic_auth) 
    5656        self.assertEqual(response.getStatus(), 200) 
    57  
     57""" 
    5858 
    5959class TestInstallation(PloneTestCase.PloneTestCase): 
     
    233233 
    234234    def test_additional_keywords_in_configlet(self): 
     235        mtool = getToolByName(self.portal, 'portal_migration') 
     236        if mtool.getFileSystemVersion() < "2.5": 
     237            return 
     238         
    235239        path = self.portal.id+'/prefs_qseo_setup?additionalKeywords=foo\nbar' 
    236240        self.publish(path, self.basic_auth) 
     
    240244 
    241245    def test_listMetaTags_empty(self): 
     246        mtool = getToolByName(self.portal, 'portal_migration') 
     247        if mtool.getFileSystemVersion() < "2.5": 
     248            return 
     249         
    242250        metatags = self.pu.listMetaTags(self.my_doc) 
    243251        self.assert_('keywords' not in metatags) 
    244252 
    245253    def test_listMetaTags_one(self): 
     254        mtool = getToolByName(self.portal, 'portal_migration') 
     255        if mtool.getFileSystemVersion() < "2.5": 
     256            return 
     257         
    246258        self.my_doc.manage_addProperty('qSEO_keywords', ('foo',), 'lines') 
    247259        metatags = self.pu.listMetaTags(self.my_doc) 
     
    250262 
    251263    def test_listMetaTags_two(self): 
     264        mtool = getToolByName(self.portal, 'portal_migration') 
     265        if mtool.getFileSystemVersion() < "2.5": 
     266            return 
     267         
    252268        self.my_doc.manage_addProperty('qSEO_keywords', ('foo', 'bar'), 'lines') 
    253269        metatags = self.pu.listMetaTags(self.my_doc) 
     
    256272 
    257273    def test_additional_keywords_in_listMetaTags_empty(self): 
     274        mtool = getToolByName(self.portal, 'portal_migration') 
     275        if mtool.getFileSystemVersion() < "2.5": 
     276            return 
     277         
    258278        self.sp.additional_keywords = ('foo',) 
    259279        metatags = self.pu.listMetaTags(self.my_doc) 
     
    261281 
    262282    def test_additional_keywords_in_listMetaTags_one(self): 
     283        mtool = getToolByName(self.portal, 'portal_migration') 
     284        if mtool.getFileSystemVersion() < "2.5": 
     285            return 
     286         
    263287        self.my_doc.setText('<p>foo</p>') 
    264288        self.sp.additional_keywords = ('foo',) 
     
    268292 
    269293    def test_additional_keywords_in_listMetaTags_two(self): 
     294        mtool = getToolByName(self.portal, 'portal_migration') 
     295        if mtool.getFileSystemVersion() < "2.5": 
     296            return 
     297         
    270298        self.my_doc.setText('<p>foo bar</p>') 
    271299        self.sp.additional_keywords = ('foo', 'bar') 
     
    275303 
    276304    def test_additional_keywords_in_listMetaTags_merge(self): 
     305        mtool = getToolByName(self.portal, 'portal_migration') 
     306        if mtool.getFileSystemVersion() < "2.5": 
     307            return 
     308         
    277309        self.my_doc.setText('<p>foo bar</p>') 
    278310        self.sp.additional_keywords = ('foo', 'bar') 
     
    332364 
    333365 
    334 TESTS = [TestBeforeInstall, TestInstallation, TestResponse, TestAdditionalKeywords, TestExposeDCMetaTags] 
     366TESTS = [TestInstallation, TestResponse, TestAdditionalKeywords, TestExposeDCMetaTags] 
    335367 
    336368def test_suite(): 
    337369    from unittest import TestSuite, makeSuite 
    338370    suite = TestSuite() 
    339     suite.addTest(makeSuite(TestBeforeInstall)) 
    340     suite.addTest(makeSuite(TestInstallation)) 
    341     suite.addTest(makeSuite(TestResponse)) 
    342     suite.addTest(makeSuite(TestAdditionalKeywords)) 
    343     suite.addTest(makeSuite(TestExposeDCMetaTags)) 
     371    for suite_class in TESTS: 
     372        suite.addTest(makeSuite(suite_class)) 
     373 
    344374    return suite 
    345375 
    346376if __name__ == '__main__': 
    347377    framework() 
    348