Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
CMFCore.tests.test_CatalogTool.CatalogToolTests Class Reference
Inheritance diagram for CMFCore.tests.test_CatalogTool.CatalogToolTests:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.tests.test_CatalogTool.CatalogToolTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_z2interfaces
def test_z3interfaces
def loginWithRoles
def loginManager
def setupProxyRoles
def test_processActions
def test_search_anonymous
def test_search_member_with_valid_roles
def test_search_member_with_valid_roles_but_proxy_roles_limit
def test_search_member_wo_valid_roles
def test_search_member_wo_valid_roles_but_proxy_roles_allow
def test_search_inactive
def test_search_restrict_manager
def test_search_restrict_inactive
def test_search_restrict_visible
def test_convertQuery
def test_refreshCatalog

Private Member Functions

def _getTargetClass
def _makeOne

Detailed Description

Definition at line 90 of file test_CatalogTool.py.


Member Function Documentation

Definition at line 92 of file test_CatalogTool.py.

00092 
00093     def _getTargetClass(self):
00094         from Products.CMFCore.CatalogTool import CatalogTool
00095 
00096         return CatalogTool

def CMFCore.tests.test_CatalogTool.CatalogToolTests._makeOne (   self,
  args,
  kw 
) [private]

Definition at line 97 of file test_CatalogTool.py.

00097 
00098     def _makeOne(self, *args, **kw):
00099         return self._getTargetClass()(*args, **kw)

Here is the call graph for this function:

Definition at line 126 of file test_CatalogTool.py.

00126 
00127     def loginManager(self):
00128         user = OmnipotentUser().__of__(self.root)
00129         newSecurityManager(None, user)

Here is the caller graph for this function:

Definition at line 122 of file test_CatalogTool.py.

00122 
00123     def loginWithRoles(self, *roles):
00124         user = UserWithRoles(*roles).__of__(self.root)
00125         newSecurityManager(None, user)

Here is the caller graph for this function:

Definition at line 130 of file test_CatalogTool.py.

00130 
00131     def setupProxyRoles(self, *proxy_roles):
00132         from AccessControl import getSecurityManager
00133         class FauxExecutable:
00134             _proxy_roles = proxy_roles
00135         sm = getSecurityManager()
00136         sm.addContext(FauxExecutable())

Here is the caller graph for this function:

Definition at line 380 of file test_CatalogTool.py.

00380 
00381     def test_convertQuery(self):
00382         convert = self._makeOne()._convertQuery
00383 
00384         kw = {}
00385         convert(kw)
00386         self.assertEqual(kw, {})
00387 
00388         kw = {'expires': 5, 'expires_usage': 'brrr:min'}
00389         self.assertRaises(ValueError, convert, kw)
00390 
00391         kw = {'foo': 'bar'}
00392         convert(kw)
00393         self.assertEqual(kw, {'foo': 'bar'})
00394 
00395         kw = {'expires': 5, 'expires_usage': 'range:min'}
00396         convert(kw)
00397         self.assertEqual(kw, {'expires': {'query': 5, 'range': 'min'}})
00398 
00399         kw = {'expires': 5, 'expires_usage': 'range:max'}
00400         convert(kw)
00401         self.assertEqual(kw, {'expires': {'query': 5, 'range': 'max'}})
00402 
00403         kw = {'expires': (5,7), 'expires_usage': 'range:min:max'}
00404         convert(kw)
00405         self.assertEqual(kw, {'expires': {'query': (5,7), 'range': 'min:max'}})

Here is the call graph for this function:

    Tracker #405:  CatalogTool doesn't accept optional third
    argument, 'idxs', to 'catalog_object'.

Definition at line 137 of file test_CatalogTool.py.

00137 
00138     def test_processActions(self):
00139         """
00140             Tracker #405:  CatalogTool doesn't accept optional third
00141             argument, 'idxs', to 'catalog_object'.
00142         """
00143         tool = self._makeOne()
00144         tool.addIndex('SearchableText', 'KeywordIndex')
00145         dummy = DummyContent(catalog=1)
00146 
00147         tool.catalog_object( dummy, '/dummy' )
00148         tool.catalog_object( dummy, '/dummy', [ 'SearchableText' ] )

Here is the call graph for this function:

Definition at line 406 of file test_CatalogTool.py.

00406 
00407     def test_refreshCatalog(self):
00408         site = DummySite('site').__of__(self.root)
00409         site._setObject('dummy', DummyContent(catalog=1))
00410         site._setObject('portal_catalog', self._makeOne())
00411         ctool = site.portal_catalog
00412         ctool.catalog_object(site.dummy, '/dummy')
00413 
00414         self.assertEqual(1, len(ctool._catalog.searchResults()))
00415         ctool.refreshCatalog(clear=1)
00416         self.assertEqual(1, len(ctool._catalog.searchResults()),
00417                          'CMF Collector issue #379 (\'Update Catalog\' '
00418                          'fails): %s entries after refreshCatalog'
00419                          % (len(ctool._catalog.searchResults()),))
00420 

Here is the call graph for this function:

Definition at line 149 of file test_CatalogTool.py.

00149 
00150     def test_search_anonymous(self):
00151         catalog = self._makeOne()
00152         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00153         dummy = DummyContent(catalog=1)
00154         catalog.catalog_object(dummy, '/dummy')
00155 
00156         self.assertEqual(1, len(catalog._catalog.searchResults()))
00157         self.assertEqual(0, len(catalog.searchResults()))

Here is the call graph for this function:

Definition at line 208 of file test_CatalogTool.py.

00208 
00209     def test_search_inactive(self):
00210         catalog = self._makeOne()
00211         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00212         catalog.addIndex('effective', 'DateIndex')
00213         catalog.addIndex('expires', 'DateIndex')
00214         now = DateTime()
00215         dummy = DummyContent(catalog=1)
00216         dummy._View_Permission = ('Blob',)
00217 
00218         self.loginWithRoles('Blob')
00219 
00220         # not yet effective
00221         dummy.effective = now+1
00222         dummy.expires = now+2
00223         catalog.catalog_object(dummy, '/dummy')
00224         self.assertEqual(1, len(catalog._catalog.searchResults()))
00225         self.assertEqual(0, len(catalog.searchResults()))
00226 
00227         # already expired
00228         dummy.effective = now-2
00229         dummy.expires = now-1
00230         catalog.catalog_object(dummy, '/dummy')
00231         self.assertEqual(1, len(catalog._catalog.searchResults()))
00232         self.assertEqual(0, len(catalog.searchResults()))

Here is the call graph for this function:

Definition at line 158 of file test_CatalogTool.py.

00158 
00159     def test_search_member_with_valid_roles(self):
00160         catalog = self._makeOne()
00161         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00162         dummy = DummyContent(catalog=1)
00163         dummy._View_Permission = ('Blob',)
00164         catalog.catalog_object(dummy, '/dummy')
00165 
00166         self.loginWithRoles('Blob')
00167 
00168         self.assertEqual(1, len(catalog._catalog.searchResults()))
00169         self.assertEqual(1, len(catalog.searchResults()))

Here is the call graph for this function:

Definition at line 170 of file test_CatalogTool.py.

00170 
00171     def test_search_member_with_valid_roles_but_proxy_roles_limit(self):
00172         catalog = self._makeOne()
00173         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00174         dummy = DummyContent(catalog=1)
00175         dummy._View_Permission = ('Blob',)
00176         catalog.catalog_object(dummy, '/dummy')
00177 
00178         self.loginWithRoles('Blob')
00179         self.setupProxyRoles('Waggle')
00180 
00181         self.assertEqual(1, len(catalog._catalog.searchResults()))
00182         self.assertEqual(0, len(catalog.searchResults()))

Here is the call graph for this function:

Definition at line 183 of file test_CatalogTool.py.

00183 
00184     def test_search_member_wo_valid_roles(self):
00185         catalog = self._makeOne()
00186         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00187         dummy = DummyContent(catalog=1)
00188         dummy._View_Permission = ('Blob',)
00189         catalog.catalog_object(dummy, '/dummy')
00190 
00191         self.loginWithRoles('Waggle')
00192 
00193         self.assertEqual(1, len(catalog._catalog.searchResults()))
00194         self.assertEqual(0, len(catalog.searchResults()))

Here is the call graph for this function:

Definition at line 195 of file test_CatalogTool.py.

00195 
00196     def test_search_member_wo_valid_roles_but_proxy_roles_allow(self):
00197         catalog = self._makeOne()
00198         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00199         dummy = DummyContent(catalog=1)
00200         dummy._View_Permission = ('Blob',)
00201         catalog.catalog_object(dummy, '/dummy')
00202 
00203         self.loginWithRoles('Waggle')
00204         self.setupProxyRoles('Blob')
00205 
00206         self.assertEqual(1, len(catalog._catalog.searchResults()))
00207         self.assertEqual(1, len(catalog.searchResults()))

Here is the call graph for this function:

Definition at line 267 of file test_CatalogTool.py.

00267 
00268     def test_search_restrict_inactive(self):
00269         catalog = self._makeOne()
00270         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00271         catalog.addIndex('effective', 'DateIndex')
00272         catalog.addIndex('expires', 'DateIndex')
00273         now = DateTime()
00274         dummy = DummyContent(catalog=1)
00275         dummy._View_Permission = ('Blob',)
00276 
00277         self.loginWithRoles('Blob')
00278 
00279         # already expired
00280         dummy.effective = now-4
00281         dummy.expires = now-2
00282         catalog.catalog_object(dummy, '/dummy')
00283         self.assertEqual(1, len(catalog._catalog.searchResults()))
00284         self.assertEqual(0, len(catalog.searchResults()))
00285 
00286         self.assertEqual(0, len(catalog.searchResults(
00287             expires={'query': now-3, 'range': 'min'})))
00288         self.assertEqual(0, len(catalog.searchResults(
00289             expires={'query': now-3, 'range': 'max'})))
00290         self.assertEqual(0, len(catalog.searchResults(
00291             expires={'query': now+3, 'range': 'min'})))
00292         self.assertEqual(0, len(catalog.searchResults(
00293             expires={'query': now+3, 'range': 'max'})))
00294         self.assertEqual(0, len(catalog.searchResults(
00295             expires={'query': (now-3, now-1), 'range': 'min:max'})))
00296         self.assertEqual(0, len(catalog.searchResults(
00297             expires={'query': (now-3, now-1), 'range': 'minmax'})))
00298         self.assertEqual(0, len(catalog.searchResults(
00299             expires={'query': now-2, 'range': None})))

Here is the call graph for this function:

Definition at line 233 of file test_CatalogTool.py.

00233 
00234     def test_search_restrict_manager(self):
00235         catalog = self._makeOne()
00236         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00237         catalog.addIndex('effective', 'DateIndex')
00238         catalog.addIndex('expires', 'DateIndex')
00239         now = DateTime()
00240         dummy = DummyContent(catalog=1)
00241 
00242         self.loginManager()
00243 
00244         # already expired
00245         dummy.effective = now-4
00246         dummy.expires = now-2
00247         catalog.catalog_object(dummy, '/dummy')
00248         self.assertEqual(1, len(catalog._catalog.searchResults()))
00249         self.assertEqual(1, len(catalog.searchResults()))
00250 
00251         self.assertEqual(1, len(catalog.searchResults(
00252             expires={'query': now-3, 'range': 'min'})))
00253         self.assertEqual(0, len(catalog.searchResults(
00254             expires={'query': now-1, 'range': 'min'})))
00255         self.assertEqual(0, len(catalog.searchResults(
00256             expires={'query': now-3, 'range': 'max'})))
00257         self.assertEqual(1, len(catalog.searchResults(
00258             expires={'query': now-1, 'range': 'max'})))
00259         self.assertEqual(1, len(catalog.searchResults(
00260             expires={'query': (now-3, now-1), 'range': 'min:max'})))
00261         self.assertEqual(1, len(catalog.searchResults(
00262             expires={'query': (now-3, now-1), 'range': 'minmax'})))
00263         self.assertEqual(1, len(catalog.searchResults(
00264             expires={'query': now-2})))
00265         self.assertEqual(1, len(catalog.searchResults(
00266             expires={'query': now-2, 'range': None})))

Here is the call graph for this function:

Definition at line 300 of file test_CatalogTool.py.

00300 
00301     def test_search_restrict_visible(self):
00302         catalog = self._makeOne()
00303         catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
00304         catalog.addIndex('effective', 'DateIndex')
00305         catalog.addIndex('expires', 'DateIndex')
00306         now = DateTime()
00307         dummy = DummyContent(catalog=1)
00308         dummy._View_Permission = ('Blob',)
00309 
00310         self.loginWithRoles('Blob')
00311 
00312         # visible
00313         dummy.effective = now-2
00314         dummy.expires = now+2
00315         catalog.catalog_object(dummy, '/dummy')
00316         self.assertEqual(1, len(catalog._catalog.searchResults()))
00317         self.assertEqual(1, len(catalog.searchResults()))
00318 
00319         self.assertEqual(0, len(catalog.searchResults(
00320             effective={'query': now-1, 'range': 'min'})))
00321         self.assertEqual(1, len(catalog.searchResults(
00322             effective={'query': now-1, 'range': 'max'})))
00323         self.assertEqual(0, len(catalog.searchResults(
00324             effective={'query': now+1, 'range': 'min'})))
00325         self.assertEqual(1, len(catalog.searchResults(
00326             effective={'query': now+1, 'range': 'max'})))
00327         self.assertEqual(0, len(catalog.searchResults(
00328             effective={'query': (now-1, now+1), 'range': 'min:max'})))
00329         self.assertEqual(0, len(catalog.searchResults(
00330             effective={'query': (now-1, now+1), 'range': 'minmax'})))
00331         self.assertEqual(1, len(catalog.searchResults(
00332             expires={'query': now-2, 'range': None})))
00333 
00334         self.assertEqual(1, len(catalog.searchResults(
00335             effective={'query': now-3, 'range': 'min'})))
00336         self.assertEqual(0, len(catalog.searchResults(
00337             effective={'query': now-3, 'range': 'max'})))
00338         self.assertEqual(0, len(catalog.searchResults(
00339             effective={'query': now+3, 'range': 'min'})))
00340         self.assertEqual(1, len(catalog.searchResults(
00341             effective={'query': now+3, 'range': 'max'})))
00342         self.assertEqual(1, len(catalog.searchResults(
00343             effective={'query': (now-3, now+3), 'range': 'min:max'})))
00344         self.assertEqual(1, len(catalog.searchResults(
00345             effective={'query': (now-3, now+3), 'range': 'minmax'})))
00346 
00347         self.assertEqual(1, len(catalog.searchResults(
00348             expires={'query': now-1, 'range': 'min'})))
00349         self.assertEqual(0, len(catalog.searchResults(
00350             expires={'query': now-1, 'range': 'max'})))
00351         self.assertEqual(1, len(catalog.searchResults(
00352             expires={'query': now+1, 'range': 'min'})))
00353         self.assertEqual(0, len(catalog.searchResults(
00354             expires={'query': now+1, 'range': 'max'})))
00355         self.assertEqual(0, len(catalog.searchResults(
00356             expires={'query': (now-1, now+1), 'range': 'min:max'})))
00357         self.assertEqual(0, len(catalog.searchResults(
00358             expires={'query': (now-1, now+1), 'range': 'minmax'})))
00359 
00360         self.assertEqual(1, len(catalog.searchResults(
00361             expires={'query': now-3, 'range': 'min'})))
00362         self.assertEqual(0, len(catalog.searchResults(
00363             expires={'query': now-3, 'range': 'max'})))
00364         self.assertEqual(0, len(catalog.searchResults(
00365             expires={'query': now+3, 'range': 'min'})))
00366         self.assertEqual(1, len(catalog.searchResults(
00367             expires={'query': now+3, 'range': 'max'})))
00368         self.assertEqual(1, len(catalog.searchResults(
00369             expires={'query': (now-3, now+3), 'range': 'min:max'})))
00370         self.assertEqual(1, len(catalog.searchResults(
00371             expires={'query': (now-3, now+3), 'range': 'minmax'})))
00372 
00373         self.assertEqual(1, len(catalog.searchResults(
00374             effective={'query': now-1, 'range': 'max'},
00375             expires={'query': now+1, 'range': 'min'})))
00376 
00377         self.assertEqual(0, len(catalog.searchResults(
00378             effective={'query': now+1, 'range': 'max'},
00379             expires={'query': now+3, 'range': 'min'})))

Here is the call graph for this function:

Definition at line 100 of file test_CatalogTool.py.

00100 
00101     def test_z2interfaces(self):
00102         from Interface.Verify import verifyClass
00103         from Products.CMFCore.interfaces.portal_actions \
00104                 import ActionProvider as IActionProvider
00105         from Products.CMFCore.interfaces.portal_catalog \
00106                 import portal_catalog as ICatalogTool
00107         from Products.ZCatalog.IZCatalog import IZCatalog
00108 
00109         verifyClass(IActionProvider, self._getTargetClass())
00110         verifyClass(ICatalogTool, self._getTargetClass())
00111         verifyClass(IZCatalog, self._getTargetClass())

Here is the call graph for this function:

Definition at line 112 of file test_CatalogTool.py.

00112 
00113     def test_z3interfaces(self):
00114         from zope.interface.verify import verifyClass
00115         from Products.CMFCore.interfaces import IActionProvider
00116         from Products.CMFCore.interfaces import ICatalogTool
00117         from Products.ZCatalog.interfaces import IZCatalog
00118 
00119         verifyClass(IActionProvider, self._getTargetClass())
00120         verifyClass(ICatalogTool, self._getTargetClass())
00121         verifyClass(IZCatalog, self._getTargetClass())

Here is the call graph for this function:


The documentation for this class was generated from the following file: