Changeset 2911 in products
- Timestamp:
- Oct 22, 2010 8:58:53 AM (14 years ago)
- Location:
- quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/tests/base.py
r2841 r2911 81 81 82 82 def beforeTearDown(self): 83 if self.orig_mobile_ifacesis not None:83 if getattr(self, 'orig_mobile_ifaces', None) is not None: 84 84 mobilesitemapview.MOBILE_INTERFACES = self.orig_mobile_ifaces 85 85 -
quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/tests/testBlackoutList.py
r2909 r2911 3 3 # 4 4 from base import * 5 from types import ListType, TupleType 5 6 from zope.component import queryUtility 6 7 8 from Products.CMFPlone.utils import _createObjectByType 7 9 from quintagroup.plonegooglesitemaps.config import BLACKOUT_PREFIX 8 10 from quintagroup.plonegooglesitemaps.interfaces import IBlackoutFilterUtility 9 11 12 idfname = BLACKOUT_PREFIX + "id" 13 pathfname = BLACKOUT_PREFIX + "path" 10 14 11 15 class TestBOFilterUtilities(TestCase): 12 16 13 17 def testDefaultIdUtility(self): 14 uname = BLACKOUT_PREFIX + "id" 15 self.assertTrue(queryUtility(IBlackoutFilterUtility, name=uname) is not None, 16 "Not registered default '%s' IBlackoutFilterUtility" % uname) 18 self.assertTrue(queryUtility(IBlackoutFilterUtility, name=idfname) is not None, 19 "Not registered default '%s' IBlackoutFilterUtility" % idfname) 17 20 18 21 def testDefaultPathUtility(self): 19 uname = BLACKOUT_PREFIX + "path" 20 self.assertTrue(queryUtility(IBlackoutFilterUtility, name=uname) is not None, 21 "Not registered default '%s' IBlackoutFilterUtility" % uname) 22 self.assertTrue(queryUtility(IBlackoutFilterUtility, name=pathfname) is not None, 23 "Not registered default '%s' IBlackoutFilterUtility" % pathfname) 22 24 25 26 class TestDefaultFilters(TestCase): 27 28 def afterSetUp(self): 29 self.loginAsPortalOwner() 30 # Add testing content to portal 31 for cont in [self.portal, self.folder]: 32 for i in range(1,4): 33 doc = _createObjectByType('Document', cont, id='my_doc%i' % i) 34 doc.edit(text_format='plain', text='hello world %i' % i) 35 self.catres = self.portal.portal_catalog(portal_type=["Document",]) 36 self.logout() 37 38 def testIdFilter(self): 39 idfilter = queryUtility(IBlackoutFilterUtility, name=idfname) 40 catpaths = [c.getPath() for c in self.catres] 41 filtered = [f.getPath() for f in idfilter.filterOut(self.catres, fkey="my_doc1")] 42 excluded = [c.getPath() for c in self.catres if c.id == "my_doc1"] 43 map(lambda l:l.sort(), [catpaths, filtered, excluded]) 44 self.assertTrue(type(filtered) in [ListType, TupleType], 45 'Object type, returned by filteredOut method of "%s" utility '\ 46 'not list nor tuple' % idfname) 47 self.assertTrue(set(catpaths)-set(filtered) == set(excluded), 48 'Wrong filtered-out by "%s" filter:\nsrc %s\nres %s\nexcluded %s' % ( 49 idfname, catpaths, filtered, excluded)) 50 51 def testPathFilter(self): 52 pathfilter = queryUtility(IBlackoutFilterUtility, name=pathfname) 53 catpaths = [c.getPath() for c in self.catres] 54 filtered = [f.getPath() for f in pathfilter.filterOut(self.catres, fkey="/plone/my_doc1")] 55 excluded = [c.getPath() for c in self.catres if c.getPath() == "/plone/my_doc1"] 56 map(lambda l:l.sort(), [catpaths, filtered, excluded]) 57 self.assertTrue(type(filtered) in [ListType, TupleType], 58 'Object type, returned by filteredOut method of "%s" utility '\ 59 'not list nor tuple' % pathfname) 60 self.assertTrue(set(catpaths)-set(filtered) == set(excluded), 61 'Wrong filtered-out by "%s" filter:\nsrc %s\nres %s\nexcluded %s' % ( 62 pathfname, catpaths, filtered, excluded)) 63 64 23 65 24 66 def test_suite(): … … 26 68 suite = TestSuite() 27 69 suite.addTest(makeSuite(TestBOFilterUtilities)) 70 suite.addTest(makeSuite(TestDefaultFilters)) 28 71 return suite 29 72
Note: See TracChangeset
for help on using the changeset viewer.