Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
CMFTopic.tests.test_Topic.TestTopic Class Reference
Inheritance diagram for CMFTopic.tests.test_Topic.TestTopic:
Inheritance graph
[legend]
Collaboration diagram for CMFTopic.tests.test_Topic.TestTopic:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def test_z2interfaces
def test_z3interfaces
def test_Empty
def test_Simple
def test_Nested
def test_selfIndexing
def test_searchableText
def test_queryCatalog_noop
def test_queryCatalog_simple
def test_synContentValues_simple
def test_synContentValues_limit

Public Attributes

 site

Static Public Attributes

 layer = EventZCMLLayer

Private Member Functions

def _getTargetClass
def _makeOne
def _initSite
def _initDocuments

Detailed Description

Test all the general Topic cases.

Definition at line 127 of file test_Topic.py.


Member Function Documentation

Definition at line 134 of file test_Topic.py.

00134 
00135     def _getTargetClass(self):
00136         from Products.CMFTopic.Topic import Topic
00137 
00138         return Topic

def CMFTopic.tests.test_Topic.TestTopic._initDocuments (   self,
  kw 
) [private]

Definition at line 149 of file test_Topic.py.

00149 
00150     def _initDocuments(self, **kw):
00151         for k, v in kw.items():
00152 
00153             document = DummyDocument( k )
00154             document.description = v
00155 
00156             self.site._setObject( k, v )
00157             self.site.portal_catalog._index( document )

Here is the caller graph for this function:

def CMFTopic.tests.test_Topic.TestTopic._initSite (   self,
  max_items = 15,
  index_ids = () 
) [private]

Definition at line 143 of file test_Topic.py.

00143 
00144     def _initSite(self, max_items=15, index_ids=()):
00145         sm = getSiteManager()
00146         self.site.portal_catalog = DummyCatalog( index_ids )
00147         self.site.portal_syndication = DummySyndicationTool( max_items )
00148         sm.registerUtility(self.site.portal_syndication, ISyndicationTool)

def CMFTopic.tests.test_Topic.TestTopic._makeOne (   self,
  id,
  args,
  kw 
) [private]

Definition at line 139 of file test_Topic.py.

00139 
00140     def _makeOne(self, id, *args, **kw):
00141         return self.site._setObject(id,
00142                                     self._getTargetClass()(id, *args, **kw))

Definition at line 158 of file test_Topic.py.

00158 
00159     def setUp(self):
00160         SecurityTest.setUp(self)
00161         self.site = DummySite('site').__of__(self.root)

Definition at line 180 of file test_Topic.py.

00180 
00181     def test_Empty( self ):
00182         topic = self._makeOne('top')
00183 
00184         query = topic.buildQuery()
00185         self.assertEqual( len( query ), 0 )

Definition at line 203 of file test_Topic.py.

00203 
00204     def test_Nested( self ):
00205         self.site._setObject( 'portal_types', TypesTool() )
00206         self.site.portal_types._setObject('Topic', FTI(id='Topic',
00207                                       product='CMFTopic', factory='addTopic'))
00208         topic = self._makeOne('top')
00209         topic._setPortalTypeName('Topic')
00210 
00211         topic.addCriterion( 'foo', 'String Criterion' )
00212         topic.getCriterion( 'foo' ).edit( 'bar' )
00213 
00214         topic.addSubtopic( 'qux' )
00215         subtopic = topic.qux
00216 
00217         subtopic.addCriterion( 'baz', 'String Criterion' )
00218         subtopic.getCriterion( 'baz' ).edit( 'bam' )
00219 
00220         query = subtopic.buildQuery()
00221         self.assertEqual( len( query ), 2 )
00222         self.assertEqual( query['foo'], 'bar' )
00223         self.assertEqual( query['baz'], 'bam' )
00224 
00225         subtopic.acquireCriteria = 0
00226         query = subtopic.buildQuery()
00227         self.assertEqual( len( query ), 1 )
00228         self.assertEqual( query['baz'], 'bam' )

Definition at line 252 of file test_Topic.py.

00252 
00253     def test_queryCatalog_noop( self ):
00254 
00255         self._initSite()
00256         self._initDocuments( **_DOCUMENTS )
00257         topic = self._makeOne('top')
00258 
00259         # Need to filter out the Topic object itself, which is also
00260         # CatalogAware and will index itself after instantiation.
00261         brains = [ x for x in topic.queryCatalog()
00262                       if x.getObject().getId() != 'top' ]
00263 
00264         self.assertEqual( len( brains ), len( _DOCUMENTS ) )
00265 
00266         objects = [ brain.getObject() for brain in brains ]
00267 
00268         for object in objects:
00269             self.failUnless( object.getId() in _DOCUMENTS.keys() )
00270             self.failUnless( object.description in _DOCUMENTS.values() )

Definition at line 271 of file test_Topic.py.

00271 
00272     def test_queryCatalog_simple( self ):
00273 
00274         WORD = 'something'
00275 
00276         self._initSite( index_ids=( 'description', ) )
00277         self._initDocuments( **_DOCUMENTS )
00278         topic = self._makeOne('top')
00279 
00280         topic.addCriterion( 'description', 'String Criterion' )
00281         topic.getCriterion( 'description' ).edit( WORD )
00282 
00283         brains = topic.queryCatalog()
00284 
00285         self.assertEqual( len( brains )
00286                         , len( [ x for x in _DOCUMENTS.values()
00287                                   if WORD in x ] ) )
00288 
00289         objects = [ brain.getObject() for brain in brains ]
00290 
00291         for object in objects:
00292             self.failUnless( object.getId() in _DOCUMENTS.keys() )
00293             self.failUnless( object.description in _DOCUMENTS.values() )

Definition at line 243 of file test_Topic.py.

00243 
00244     def test_searchableText(self):
00245         # Test the catalog helper
00246         topic = self._makeOne('top')
00247         topic.edit(False, title='FOO', description='BAR')
00248 
00249         st = topic.SearchableText()
00250         self.failUnless(st.find('BAR') != -1)
00251         self.failUnless(st.find('FOO') != -1)

Definition at line 229 of file test_Topic.py.

00229 
00230     def test_selfIndexing(self):
00231         # The Topic object is CatalogAware and should be in the catalog
00232         # after it has beeen instantiated.
00233         self._initSite()
00234         topic = self._makeOne('top')
00235 
00236         # A topic without criteria will return a full catalog search result
00237         # set, so we should not have one result, for the Topic object itself.
00238         results = topic.queryCatalog()
00239 
00240         self.assertEquals(len(results), 1)
00241         self.assertEquals(results[0].getObject().getId(), topic.getId())
00242         self.assertEquals(results[0].getObject(), topic)

Definition at line 186 of file test_Topic.py.

00186 
00187     def test_Simple( self ):
00188         topic = self._makeOne('top')
00189         topic.addCriterion( 'foo', 'String Criterion' )
00190         topic.getCriterion( 'foo' ).edit( 'bar' )
00191 
00192         query = topic.buildQuery()
00193         self.assertEqual( len(query), 1 )
00194         self.assertEqual( query['foo'], 'bar' )
00195 
00196         topic.addCriterion( 'baz', 'Integer Criterion' )
00197         topic.getCriterion( 'baz' ).edit( 43 )
00198 
00199         query = topic.buildQuery()
00200         self.assertEqual( len( query ), 2 )
00201         self.assertEqual( query[ 'foo' ], 'bar' )
00202         self.assertEqual( query[ 'baz' ], 43 )

Definition at line 314 of file test_Topic.py.

00314 
00315     def test_synContentValues_limit( self ):
00316 
00317         LIMIT = 3
00318 
00319         self._initSite( max_items=LIMIT )
00320         self._initDocuments( **_DOCUMENTS )
00321         topic = self._makeOne('top')
00322 
00323         brains = topic.synContentValues()
00324 
00325         self.assertEqual( len( brains ), LIMIT )
00326 
00327         objects = [ brain.getObject() for brain in brains ]
00328 
00329         for object in objects:
00330             self.failUnless( object.getId() in _DOCUMENTS.keys() )
00331             self.failUnless( object.description in _DOCUMENTS.values() )
00332 

Definition at line 294 of file test_Topic.py.

00294 
00295     def test_synContentValues_simple( self ):
00296 
00297         self._initSite()
00298         self._initDocuments( **_DOCUMENTS )
00299         topic = self._makeOne('top')
00300 
00301         #brains = topic.synContentValues()
00302         # Need to filter out the Topic object itself, which is also
00303         # CatalogAware and will index itself after instantiation.
00304         brains = [ x for x in topic.synContentValues()
00305                       if x.getObject().getId() != 'top' ]
00306 
00307         self.assertEqual( len( brains ), len( _DOCUMENTS ) )
00308 
00309         objects = [ brain.getObject() for brain in brains ]
00310 
00311         for object in objects:
00312             self.failUnless( object.getId() in _DOCUMENTS.keys() )
00313             self.failUnless( object.description in _DOCUMENTS.values() )

Definition at line 162 of file test_Topic.py.

00162 
00163     def test_z2interfaces(self):
00164         from Interface.Verify import verifyClass
00165         from OFS.IOrderSupport import IOrderedContainer
00166 
00167         verifyClass(IOrderedContainer, self._getTargetClass())

Definition at line 168 of file test_Topic.py.

00168 
00169     def test_z3interfaces(self):
00170         from zope.interface.verify import verifyClass
00171         from OFS.interfaces import IOrderedContainer
00172         from Products.CMFCore.interfaces import IContentish
00173         from Products.CMFTopic.interfaces import IMutableTopic
00174         from Products.CMFTopic.interfaces import ITopic
00175 
00176         verifyClass(IContentish, self._getTargetClass())
00177         verifyClass(IMutableTopic, self._getTargetClass())
00178         verifyClass(ITopic, self._getTargetClass())
00179         verifyClass(IOrderedContainer, self._getTargetClass())


Member Data Documentation

CMFTopic.tests.test_Topic.TestTopic.layer = EventZCMLLayer [static]

Definition at line 132 of file test_Topic.py.

Definition at line 160 of file test_Topic.py.


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