Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
CMFPlone.tests.testCatalogTool.TestCatalogIndexing Class Reference
Inheritance diagram for CMFPlone.tests.testCatalogTool.TestCatalogIndexing:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.tests.testCatalogTool.TestCatalogIndexing:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def assertResults
def testFixture
def testIndexObject
def testReindexObject
def testUnindexObject
def testIndexObjectUpdatesMetadata
def testReindexObjectUpdatesMetadata
def testReindexObjectSkipsMetadata
def testReindexTitleOnly
def testReindexTitleOnlyUpdatesMetadata
def testReindexTitleOnlySkipsMetadata
def testIndexTitleOnly
def testIndexIdOnly
def testClearFindAndRebuildRemovesBadContent
def testClearFindAndRebuildAddsMissingContent
def testClearFindAndRebuildKeepsModificationDate
def setRequestMethod
def getAuthenticator
def setupAuthenticator

Public Attributes

 catalog

Detailed Description

Definition at line 146 of file testCatalogTool.py.


Member Function Documentation

Definition at line 148 of file testCatalogTool.py.

00148 
00149     def afterSetUp(self):
00150         self.catalog = self.portal.portal_catalog
00151         self.folder.invokeFactory('Document', id='doc', title='Foo', description='Bar')
00152         self.catalog.unindexObject(self.folder.doc)

Definition at line 153 of file testCatalogTool.py.

00153 
00154     def assertResults(self, result, expect):
00155         # Verifies ids of catalog results against expected ids
00156         lhs = [r.getId for r in result]
00157         lhs.sort()
00158         rhs = list(expect)
00159         rhs.sort()
00160         self.assertEqual(lhs, rhs)

Here is the caller graph for this function:

Definition at line 30 of file PloneTestCase.py.

00030 
00031     def getAuthenticator(self):
00032         tag = AuthenticatorView('context', 'request').authenticator()
00033         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00034         return match(pattern, tag).groups()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.tests.PloneTestCase.PloneTestCase.setRequestMethod (   self,
  method 
) [inherited]
This is a stub now, but in case you want to try
   something fancy on Your Branch (tm), put it here.

Definition at line 26 of file PloneTestCase.py.

00026 
00027     def setRequestMethod(self, method):
00028         self.app.REQUEST.set('REQUEST_METHOD', method)
00029         self.app.REQUEST.method = method

Here is the caller graph for this function:

Definition at line 35 of file PloneTestCase.py.

00035 
00036     def setupAuthenticator(self):
00037         name, token = self.getAuthenticator()
00038         self.app.REQUEST.form[name] = token
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 302 of file testCatalogTool.py.

00302 
00303     def testClearFindAndRebuildAddsMissingContent(self):
00304         # Index the doc for consistency
00305         self.catalog.indexObject(self.folder.doc)
00306         res = self.catalog.searchResults()
00307         self.assertResults(res, base_content)
00308         # index an object which shouldn't be there
00309         self.catalog.unindexObject(self.portal.Members)
00310         altered_content = base_content[:]
00311         altered_content.remove('Members')
00312         res = self.catalog.searchResults()
00313         self.assertResults(res, altered_content)
00314         self.catalog.clearFindAndRebuild()
00315         # This will add the missing item and also the document added
00316         # in afterSetup
00317         res = self.catalog.searchResults()
00318         self.assertResults(res, base_content)

Here is the call graph for this function:

Definition at line 319 of file testCatalogTool.py.

00319 
00320     def testClearFindAndRebuildKeepsModificationDate(self):
00321         # Index the doc for consistency
00322         self.catalog.indexObject(self.folder.doc)
00323         self.folder.doc.setModificationDate(DateTime(0))
00324         self.catalog.clearFindAndRebuild()
00325         self.assertEquals(self.folder.doc.modified(), DateTime(0))
00326         self.assertEquals(len(self.catalog(modified=DateTime(0))), 1)
00327 

Definition at line 287 of file testCatalogTool.py.

00287 
00288     def testClearFindAndRebuildRemovesBadContent(self):
00289         # Index the doc for consistency
00290         self.catalog.indexObject(self.folder.doc)
00291         res = self.catalog.searchResults()
00292         self.assertResults(res, base_content)
00293         # index an object which shouldn't be there
00294         self.catalog.indexObject(self.portal.portal_skins)
00295         res = self.catalog.searchResults()
00296         self.assertResults(res, base_content+['portal_skins'])
00297         self.catalog.clearFindAndRebuild()
00298         # This will remove the extraneous item and add the document added
00299         # in afterSetup
00300         res = self.catalog.searchResults()
00301         self.assertResults(res, base_content)

Here is the call graph for this function:

Definition at line 161 of file testCatalogTool.py.

00161 
00162     def testFixture(self):
00163         self.assertEqual(self.folder.doc.getId(), 'doc')
00164         self.assertEqual(self.folder.doc.Title(), 'Foo')
00165         self.assertEqual(self.folder.doc.Description(), 'Bar')
00166         self.assertEqual(len(self.catalog(getId='doc')), 0)
00167         self.assertEqual(len(self.catalog(Title='Foo')), 0)
00168         self.assertEqual(len(self.catalog(Description='Bar')), 0)

Definition at line 272 of file testCatalogTool.py.

00272 
00273     def testIndexIdOnly(self):
00274         # Indexing should only index the id
00275         #
00276         # TODO: Demonstrate that the behavior is independent
00277         # of index type.
00278         #
00279         self.catalog.indexObject(self.folder.doc, idxs=['getId'])
00280         # The document is cataloged
00281         path = self.catalog._CatalogTool__url(self.folder.doc)
00282         self.failUnless(path in self.catalog._catalog.paths.values())
00283         # But it is not returned when searching...
00284         self.assertEqual(len(self.catalog(getId='doc')), 0) # <-- Should be 1
00285         self.assertEqual(len(self.catalog(Title='Foo')), 0)
00286         self.assertEqual(len(self.catalog(Description='Bar')), 0)

Definition at line 169 of file testCatalogTool.py.

00169 
00170     def testIndexObject(self):
00171         # Object should be indexed
00172         self.catalog.indexObject(self.folder.doc)
00173         self.assertEqual(len(self.catalog(getId='doc')), 1)
00174         self.assertEqual(len(self.catalog(Title='Foo')), 1)
00175         self.assertEqual(len(self.catalog(Description='Bar')), 1)

Definition at line 190 of file testCatalogTool.py.

00190 
00191     def testIndexObjectUpdatesMetadata(self):
00192         # Indexing should update metadata
00193         self.catalog.indexObject(self.folder.doc)
00194         brain = self.catalog(getId='doc')[0]
00195         self.assertEqual(brain.getId, 'doc')
00196         self.assertEqual(brain.Title, 'Foo')
00197         self.assertEqual(brain.Description, 'Bar')

Definition at line 256 of file testCatalogTool.py.

00256 
00257     def testIndexTitleOnly(self):
00258         # Indexing should only index the Title
00259         #
00260         # TODO: This does not work as expected. The object
00261         # appears to be in the catalog but is not returned
00262         # by searchResults()!?
00263         #
00264         self.catalog.indexObject(self.folder.doc, idxs=['Title'])
00265         # The document is cataloged
00266         path = self.catalog._CatalogTool__url(self.folder.doc)
00267         self.failUnless(path in self.catalog._catalog.paths.values())
00268         # But it is not returned when searching...
00269         self.assertEqual(len(self.catalog(getId='doc')), 0)
00270         self.assertEqual(len(self.catalog(Title='Foo')), 0) # <-- Should be 1
00271         self.assertEqual(len(self.catalog(Description='Bar')), 0)

Definition at line 176 of file testCatalogTool.py.

00176 
00177     def testReindexObject(self):
00178         # Object should be indexed
00179         self.catalog.reindexObject(self.folder.doc)
00180         self.assertEqual(len(self.catalog(getId='doc')), 1)
00181         self.assertEqual(len(self.catalog(Title='Foo')), 1)
00182         self.assertEqual(len(self.catalog(Description='Bar')), 1)

Definition at line 209 of file testCatalogTool.py.

00209 
00210     def testReindexObjectSkipsMetadata(self):
00211         # Reindexing should not update metadata when update_metadata=0
00212         self.catalog.indexObject(self.folder.doc)
00213         self.folder.doc.setTitle('Fred')
00214         self.folder.doc.setDescription('BamBam')
00215         self.catalog.reindexObject(self.folder.doc, update_metadata=0)
00216         brain = self.catalog(getId='doc')[0]
00217         # Metadata did not change
00218         self.assertEqual(brain.getId, 'doc')
00219         self.assertEqual(brain.Title, 'Foo')
00220         self.assertEqual(brain.Description, 'Bar')

Definition at line 198 of file testCatalogTool.py.

00198 
00199     def testReindexObjectUpdatesMetadata(self):
00200         # Reindexing should update metadata
00201         self.catalog.indexObject(self.folder.doc)
00202         self.folder.doc.setTitle('Fred')
00203         self.folder.doc.setDescription('BamBam')
00204         self.catalog.reindexObject(self.folder.doc)
00205         brain = self.catalog(getId='doc')[0]
00206         self.assertEqual(brain.getId, 'doc')
00207         self.assertEqual(brain.Title, 'Fred')
00208         self.assertEqual(brain.Description, 'BamBam')

Definition at line 221 of file testCatalogTool.py.

00221 
00222     def testReindexTitleOnly(self):
00223         # Reindexing should only index the Title
00224         self.catalog.indexObject(self.folder.doc)
00225         self.folder.doc.setTitle('Fred')
00226         self.folder.doc.setDescription('BamBam')
00227         self.catalog.reindexObject(self.folder.doc, idxs=['Title'])
00228         self.assertEqual(len(self.catalog(getId='doc')), 1)
00229         self.assertEqual(len(self.catalog(Title='Fred')), 1)
00230         # Description index did not change
00231         self.assertEqual(len(self.catalog(Description='Bar')), 1)
00232         self.assertEqual(len(self.catalog(Description='BamBam')), 0)

Definition at line 244 of file testCatalogTool.py.

00244 
00245     def testReindexTitleOnlySkipsMetadata(self):
00246         # Reindexing Title should not update metadata when update_metadata=0
00247         self.catalog.indexObject(self.folder.doc)
00248         self.folder.doc.setTitle('Fred')
00249         self.folder.doc.setDescription('BamBam')
00250         self.catalog.reindexObject(self.folder.doc, idxs=['Title'], update_metadata=0)
00251         brain = self.catalog(getId='doc')[0]
00252         # Metadata did not change
00253         self.assertEqual(brain.getId, 'doc')
00254         self.assertEqual(brain.Title, 'Foo')
00255         self.assertEqual(brain.Description, 'Bar')

Definition at line 233 of file testCatalogTool.py.

00233 
00234     def testReindexTitleOnlyUpdatesMetadata(self):
00235         # Reindexing Title should update metadata
00236         self.catalog.indexObject(self.folder.doc)
00237         self.folder.doc.setTitle('Fred')
00238         self.folder.doc.setDescription('BamBam')
00239         self.catalog.reindexObject(self.folder.doc, idxs=['Title'])
00240         brain = self.catalog(getId='doc')[0]
00241         self.assertEqual(brain.getId, 'doc')
00242         self.assertEqual(brain.Title, 'Fred')
00243         self.assertEqual(brain.Description, 'BamBam')

Definition at line 183 of file testCatalogTool.py.

00183 
00184     def testUnindexObject(self):
00185         # Object should be unindexed
00186         self.catalog.indexObject(self.folder.doc)
00187         self.assertEqual(len(self.catalog(getId='doc')), 1)
00188         self.catalog.unindexObject(self.folder.doc)
00189         self.assertEqual(len(self.catalog(getId='doc')), 0)


Member Data Documentation

Definition at line 149 of file testCatalogTool.py.


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