Changeset 2750 in products


Ignore:
Timestamp:
Aug 13, 2010 1:06:26 PM (10 years ago)
Author:
mylan
Message:

#229: Added test for functions used in additional_maps in news sitemaps view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py

    r2747 r2750  
    11from base import * 
    22from DateTime import DateTime 
    3  
     3from Missing import MV 
     4 
     5from zope.publisher.browser import TestRequest 
     6from zope.component import queryMultiAdapter 
    47from zope.component import adapts, provideAdapter 
     8from zope.annotation.interfaces import IAttributeAnnotatable 
    59from zope.component import getSiteManager, getGlobalSiteManager 
    610from zope.interface import implements, Interface, classImplements 
     
    239243 
    240244 
     245 
     246classImplements(TestRequest, IAttributeAnnotatable) 
     247 
     248class TestAdditionalMaps(TestCase): 
     249    """Test bug in processing Missing value in functions, 
     250       defined in additional_maps property. 
     251    """ 
     252    mv_keys = ['Date', 'Subject', 'getId', 'Language', 
     253               'gsm_access', 'gsm_genres', 'gsm_stock'] 
     254 
     255    def afterSetUp(self): 
     256        super(TestAdditionalMaps, self).afterSetUp() 
     257        # Create news sitemaps  
     258        _createObjectByType("Sitemap", self.portal, id="news-sitemaps", 
     259                            sitemapType="news") 
     260        context = self.portal['news-sitemaps'] 
     261        self.nsmv = queryMultiAdapter((context, TestRequest()), name="news-sitemap.xml") 
     262 
     263        self.brain = self.portal.portal_catalog(portal_type="Document")[0] 
     264        for k in self.mv_keys: 
     265            self.brain[k] = MV 
     266         
     267    def testAdditionalMaps(self): 
     268        for n,func in self.nsmv.additional_maps: 
     269            try: 
     270                v = func(self.brain) 
     271            except Exception, e: 
     272                self.fail("Wrong processing 'Missing' value for '%s': %s" 
     273                          % (n, str(e))) 
     274                 
     275                 
    241276def test_suite(): 
    242277    from unittest import TestSuite, makeSuite 
     
    246281    suite.addTest(makeSuite(TestSchemaExtending)) 
    247282    suite.addTest(makeSuite(TestNotOverrideExistingSchemaExtender)) 
     283    suite.addTest(makeSuite(TestAdditionalMaps)) 
    248284    return suite 
Note: See TracChangeset for help on using the changeset viewer.