Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Attributes
ATContentTypes.tests.test_attopic.TestSiteATTopic Class Reference
Inheritance diagram for ATContentTypes.tests.test_attopic.TestSiteATTopic:
Inheritance graph
[legend]
Collaboration diagram for ATContentTypes.tests.test_attopic.TestSiteATTopic:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def test_implementsATTopic
def test_Z3implementsATTopic
def test_isNotOrdered
def test_Empty
def test_canContainSubtopics
def test_Simple
def test_nested
def test_edit
def test_hasSubTopics
def test_queryCatalogBatching
def test_queryCatalogBatchingWithLimit
def test_queryCatalogBrains
def test_queryCatalogLimitChangesBatchSize
def test_queryCatalogBSizeChangesBatchSize
def test_get_size
def test_syndication_enabled_by_default
def test_schema_marshall
def test_sort_criterion_does_not_affect_available_fields
def test_000testsetup
def test_dcEdit
def test_typeInfo
def test_doesImplementDC
def test_doesImplementATCT
def test_doesImplementZ3ATCT
def test_doesImplementAT
def test_implementsTranslateable
def test_not_implements_ITemplateMixin
def test_implements_ISelectableBrowserDefault
def compareDC
def test_idValidation
def test_getobjpositioninparent
def beforeTearDown

Static Public Attributes

 klass = ATTopic
string portal_type = 'Topic'
string title = 'Collection'
string meta_type = 'ATTopic'
string icon = 'topic_icon.gif'
 cmf_klass = None
string cmf_portal_type = ''

Private Attributes

 _ATCT

Detailed Description

Definition at line 156 of file test_attopic.py.


Member Function Documentation

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 164 of file test_attopic.py.

00164 
00165     def afterSetUp(self):
00166         self.setRoles(['Manager', 'Member'])
00167         self._ATCT = self._createType(self.folder, self.portal_type, 'ATCT')
00168         self.setRoles(['Member'])

Here is the call graph for this function:

Definition at line 231 of file atcttestcase.py.

00231 
00232     def beforeTearDown(self):
00233         self.logout()

Here is the call graph for this function:

def ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.compareDC (   self,
  first,
  second = None,
  kwargs 
) [inherited]

Definition at line 181 of file atcttestcase.py.

00181 
00182     def compareDC(self, first, second=None, **kwargs):
00183         """
00184         """
00185         if second != None:
00186             title = second.Title()
00187             description = second.Description()
00188         else:
00189             title = kwargs.get('title')
00190             description = kwargs.get('description')
00191 
00192         self.failUnlessEqual(first.Title(), title)
00193         self.failUnlessEqual(first.Description(), description)

Here is the caller graph for this function:

Definition at line 107 of file atcttestcase.py.

00107 
00108     def test_000testsetup(self):
00109         # test if we really have the right test setup
00110         # vars
00111         self.failUnless(self.klass)
00112         self.failUnless(self.portal_type)
00113         self.failUnless(self.title)
00114         self.failUnless(self.meta_type)
00115         self.failUnless(self.icon)
00116         if self.cmf_klass:
00117             self.failUnless(self.cmf_klass)
00118             self.failUnless(self.cmf_portal_type)
00119 
00120         # portal types
00121         self.failUnlessEqual(self._ATCT.portal_type, self.portal_type)
00122         if self.cmf_klass:
00123             self.failUnlessEqual(self._cmf.portal_type, self.cmf_portal_type)
00124 
00125         # classes
00126         atct_class = self._ATCT.__class__
00127         self.failUnlessEqual(self.klass, atct_class)
00128         if self.cmf_klass:
00129             cmf_class = self._cmf.__class__
00130             self.failUnlessEqual(self.cmf_klass, cmf_class)

Definition at line 189 of file test_attopic.py.

00189 
00190     def test_canContainSubtopics(self):
00191         ttool = self.portal.portal_types
00192         fti = ttool.getTypeInfo(self.portal_type)
00193         self.failUnless(self.portal_type in fti.allowed_content_types,
00194                         'Topics should be allowed to contain topics')

Reimplemented in ATContentTypes.tests.test_atimage.TestSiteATImage.

Definition at line 131 of file atcttestcase.py.

00131 
00132     def test_dcEdit(self):
00133         new = self._ATCT
00134         dcEdit(new)
00135         if self.cmf_klass:
00136             old = self._cmf
00137             dcEdit(old)
00138             self.compareDC(old, new)

Here is the call graph for this function:

Definition at line 160 of file atcttestcase.py.

00160 
00161     def test_doesImplementAT(self):
00162         self.failUnless(IBaseContent.isImplementedBy(self._ATCT))
00163         self.failUnless(IReferenceable.isImplementedBy(self._ATCT))
00164         self.failUnless(verifyObject(IBaseContent, self._ATCT))
00165         self.failUnless(verifyObject(IReferenceable, self._ATCT))

Definition at line 152 of file atcttestcase.py.

00152 
00153     def test_doesImplementATCT(self):
00154         self.failUnless(IATContentType.isImplementedBy(self._ATCT))
00155         self.failUnless(verifyObject(IATContentType, self._ATCT))

Definition at line 146 of file atcttestcase.py.

00146 
00147     def test_doesImplementDC(self):
00148         self.failUnless(IDublinCore.isImplementedBy(self._ATCT))
00149         self.failUnless(IMutableDublinCore.isImplementedBy(self._ATCT))
00150         self.failUnless(verifyObject(IDublinCore, self._ATCT))
00151         self.failUnless(verifyObject(IMutableDublinCore, self._ATCT))

Definition at line 156 of file atcttestcase.py.

00156 
00157     def test_doesImplementZ3ATCT(self):
00158         iface = Z3IATContentType
00159         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 248 of file test_attopic.py.

00248 
00249     def test_edit(self):
00250         new = self._ATCT
00251         editATCT(new)

Here is the call graph for this function:

Definition at line 183 of file test_attopic.py.

00183 
00184     def test_Empty( self ):
00185         topic = self._ATCT
00186 
00187         query = topic.buildQuery()
00188         self.assertEquals( query, None )

Definition at line 328 of file test_attopic.py.

00328 
00329     def test_get_size(self):
00330         atct = self._ATCT
00331         self.failUnlessEqual(atct.get_size(), 1)

Definition at line 215 of file atcttestcase.py.

00215 
00216     def test_getobjpositioninparent(self):
00217         # TODO: not a real test
00218         self._ATCT.getObjPositionInParent()

Definition at line 252 of file test_attopic.py.

00252 
00253     def test_hasSubTopics(self):
00254         #Ensure that has subtopics returns True if there are subtopics,
00255         #    false otherwise
00256         topic = self._ATCT
00257         self.failUnlessEqual(topic.hasSubtopics(), False)
00258         self.setRoles(['Manager', 'Member'])
00259         topic.invokeFactory('Topic', 'subtopic')
00260         self.setRoles(['Member'])
00261         self.failUnlessEqual(topic.hasSubtopics(), True)

Here is the call graph for this function:

Definition at line 194 of file atcttestcase.py.

00194 
00195     def test_idValidation(self):
00196         self.setRoles(['Manager', 'Member']) # for ATTopic
00197         asdf = self._createType(self.folder, self.portal_type, 'asdf')
00198         asdf2 = self._createType(self.folder, self.portal_type, 'asdf2')
00199         self.setRoles(['Member'])
00200 
00201         request = FakeRequestSession()
00202 
00203         # invalid ids
00204         ids = ['asdf2', '???', '/asdf2', ' asdf2', 'portal_workflow',
00205             'portal_url']
00206         for id in ids:
00207             request.form = {'id':id, 'fieldset':'default'}
00208             self.assertNotEquals(asdf.validate(REQUEST=request), {}, "Not catched id: %s" % id)
00209 
00210         # valid ids
00211         ids = ['', 'abcd', 'blafasel']
00212         for id in ids:
00213             request.form = {'id':id}
00214             self.assertEquals(asdf.validate(REQUEST=request), {})

Here is the call graph for this function:

Definition at line 176 of file atcttestcase.py.

00176 
00177     def test_implements_ISelectableBrowserDefault(self):
00178         iface = ISelectableBrowserDefault
00179         self.failUnless(iface.providedBy(self._ATCT))
00180         self.failUnless(Z3verifyObject(iface, self._ATCT))

Definition at line 169 of file test_attopic.py.

00169 
00170     def test_implementsATTopic(self):
00171         iface = IATTopic
00172         self.failUnless(iface.isImplementedBy(self._ATCT))
00173         self.failUnless(verifyObject(iface, self._ATCT))

Definition at line 166 of file atcttestcase.py.

00166 
00167     def test_implementsTranslateable(self):
00168         # lingua plone is adding the ITranslatable interface to all types
00169         if not HAS_LINGUA_PLONE:
00170             return
00171         self.failUnless(ITranslatable.isImplementedBy(self._ATCT))
00172         self.failUnless(verifyObject(ITranslatable, self._ATCT))

Definition at line 178 of file test_attopic.py.

00178 
00179     def test_isNotOrdered(self):
00180         iface = IZopeOrderedContainer
00181         self.failIf(iface.isImplementedBy(self._ATCT))
00182         self.failIf(iface.isImplementedByInstancesOf(self.klass))

Definition at line 215 of file test_attopic.py.

00215 
00216     def test_nested( self ):
00217         topic = self._ATCT
00218 
00219         topic.addCriterion( 'foo', 'ATSimpleStringCriterion' )
00220         self.failUnless('crit__foo_ATSimpleStringCriterion' in
00221             topic.objectIds(), topic.objectIds())
00222         topic.getCriterion( 'foo_ATSimpleStringCriterion' ).setValue( 'bar' )
00223 
00224         self.setRoles(['Manager', 'Member'])
00225         topic.addSubtopic( 'qux' )
00226         self.setRoles(['Member'])
00227         subtopic = topic.qux
00228 
00229         subtopic.setAcquireCriteria(True)
00230 
00231         #Ensure an empty subtopic uses it's parents' queries
00232         self.failUnlessEqual(subtopic.buildQuery(), topic.buildQuery())
00233 
00234         subtopic.addCriterion( 'baz', 'ATSimpleStringCriterion' )
00235         self.failUnless('crit__baz_ATSimpleStringCriterion' in
00236             subtopic.objectIds(), subtopic.objectIds())
00237         subtopic.getCriterion( 'baz_ATSimpleStringCriterion' ).setValue( 'bam' )
00238 
00239         query = subtopic.buildQuery()
00240         self.assertEquals( len( query ), 2 )
00241         self.assertEquals( query['foo'], 'bar' )
00242         self.assertEquals( query['baz'], 'bam' )
00243 
00244         subtopic.setAcquireCriteria(False)
00245         query = subtopic.buildQuery()
00246         self.assertEquals( len( query ), 1 )
00247         self.assertEquals( query['baz'], 'bam' )

Here is the call graph for this function:

Definition at line 173 of file atcttestcase.py.

00173 
00174     def test_not_implements_ITemplateMixin(self):
00175         self.failIf(ITemplateMixin.isImplementedBy(self._ATCT))

Definition at line 262 of file test_attopic.py.

00262 
00263     def test_queryCatalogBatching(self):
00264         # Ensure that has we return a proper batch if requested
00265         topic = self._ATCT
00266         self.failUnless(isinstance(topic.queryCatalog(batch=True),Batch))
00267         self.failIf(isinstance(topic.queryCatalog(),Batch))
00268         # try it with some content now
00269         crit = topic.addCriterion('portal_type', 'ATSimpleStringCriterion')
00270         crit.setValue('Folder')
00271         self.failUnless(isinstance(topic.queryCatalog(batch=True),Batch))
00272         self.failIf(isinstance(topic.queryCatalog(),Batch))

Definition at line 273 of file test_attopic.py.

00273 
00274     def test_queryCatalogBatchingWithLimit(self):
00275         # Ensure that the number of results is the same with or without a
00276         # limit
00277         topic = self._ATCT
00278         crit = topic.addCriterion('portal_type', 'ATSimpleStringCriterion')
00279         crit.setValue('Folder')
00280         # set a sort criterion because sort_limit affects result batching.
00281         topic.setSortCriterion('created', False)
00282         # add a few folders
00283         for i in range(6):
00284             self.folder.invokeFactory('Folder', 'folder_%s'%i)
00285             getattr(self.folder, 'folder_%s'%i).reindexObject()
00286         num_items = len(topic.queryCatalog())
00287         # We better have some folders
00288         self.failUnless(num_items >= 6)
00289         self.assertEqual(topic.queryCatalog(batch=True).sequence_length, num_items)
00290         # Set some limits
00291         topic.setLimitNumber(True)
00292         topic.setItemCount(2)
00293         self.assertEqual(topic.queryCatalog(batch=True).sequence_length, num_items)

Here is the call graph for this function:

Definition at line 294 of file test_attopic.py.

00294 
00295     def test_queryCatalogBrains(self):
00296         #Ensure that we feturn full objects when requested
00297         topic = self._ATCT
00298         crit = topic.addCriterion('portal_type', 'ATSimpleStringCriterion')
00299         crit.setValue('Folder')
00300         self.failUnless(isinstance(topic.queryCatalog(full_objects=True)[0], ATFolder))
00301         self.failIf(isinstance(topic.queryCatalog()[0], ATFolder))

Definition at line 316 of file test_attopic.py.

00316 
00317     def test_queryCatalogBSizeChangesBatchSize(self):
00318         #Ensure that a set limit overrides batch size
00319         topic = self._ATCT
00320         crit = topic.addCriterion('portal_type', 'ATSimpleStringCriterion')
00321         crit.setValue('Folder')
00322         # Add a bunch of folders.
00323         for i in range(1, 20):
00324             self.folder.invokeFactory('Folder', str(i))
00325         self.failUnless(isinstance(topic.queryCatalog(batch=True, b_size=5),Batch))
00326         # Check the batch length
00327         self.assertEqual(len(topic.queryCatalog(batch=True, b_size=5)), 5)

Definition at line 302 of file test_attopic.py.

00302 
00303     def test_queryCatalogLimitChangesBatchSize(self):
00304         #Ensure that a set limit overrides batch size
00305         topic = self._ATCT
00306         topic.setLimitNumber(True)
00307         topic.setItemCount(10)
00308         crit = topic.addCriterion('portal_type', 'ATSimpleStringCriterion')
00309         crit.setValue('Folder')
00310         # Add a bunch of folders.
00311         for i in range(1, 20):
00312             self.folder.invokeFactory('Folder', str(i))
00313         self.failUnless(isinstance(topic.queryCatalog(batch=True),Batch))
00314         # Check the batch length
00315         self.assertEqual(len(topic.queryCatalog(batch=True)), 10)

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 336 of file test_attopic.py.

00336 
00337     def test_schema_marshall(self):
00338         pass

Definition at line 195 of file test_attopic.py.

00195 
00196     def test_Simple( self ):
00197         topic = self._ATCT
00198 
00199         topic.addCriterion( 'foo', 'ATSimpleStringCriterion' )
00200         self.failUnless('crit__foo_ATSimpleStringCriterion' in
00201             topic.objectIds(), topic.objectIds())
00202         topic.getCriterion( 'foo_ATSimpleStringCriterion' ).setValue( 'bar' )
00203 
00204         query = topic.buildQuery()
00205         self.assertEquals( len(query), 1 )
00206         self.assertEquals( query['foo'], 'bar' )
00207 
00208         topic.addCriterion( 'baz', 'ATSimpleIntCriterion' )
00209         topic.getCriterion( 'baz_ATSimpleIntCriterion' ).setValue( '43' )
00210 
00211         query = topic.buildQuery()
00212         self.assertEquals( len( query ), 2 )
00213         self.assertEquals( query[ 'foo' ], 'bar' )
00214         self.assertEquals( query[ 'baz' ], {'query': 43} )

Definition at line 339 of file test_attopic.py.

00339 
00340     def test_sort_criterion_does_not_affect_available_fields(self):
00341         topic = self._ATCT
00342         # set a sort criterion
00343         topic.setSortCriterion('created', False)
00344         # It should still be available for other criteria
00345         self.failUnless([i for i in topic.listAvailableFields()
00346                          if i[0] == 'created'])
00347         # Add a normal criteria for the same field
00348         crit = topic.addCriterion('created', 'ATFriendlyDateCriteria')
00349         # It should no longer be available
00350         self.failIf([i for i in topic.listAvailableFields()
00351                      if i[0] == 'created'])
00352 
00353 
00354 tests.append(TestSiteATTopic)

Definition at line 332 of file test_attopic.py.

00332 
00333     def test_syndication_enabled_by_default(self):
00334         syn = self.portal.portal_syndication
00335         self.failUnless(syn.isSyndicationAllowed(self._ATCT))

Definition at line 139 of file atcttestcase.py.

00139 
00140     def test_typeInfo(self):
00141         ti = self._ATCT.getTypeInfo()
00142         self.failUnlessEqual(ti.getId(), self.portal_type)
00143         self.failUnlessEqual(ti.Title(), self.title)
00144         self.failUnlessEqual(ti.getIcon(), self.icon)
00145         self.failUnlessEqual(ti.Metatype(), self.meta_type)

Definition at line 174 of file test_attopic.py.

00174 
00175     def test_Z3implementsATTopic(self):
00176         iface = Z3IATTopic
00177         self.failUnless(Z3verifyObject(iface, self._ATCT))


Member Data Documentation

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 166 of file test_attopic.py.

Definition at line 82 of file atcttestcase.py.

Definition at line 84 of file atcttestcase.py.

string ATContentTypes.tests.test_attopic.TestSiteATTopic.icon = 'topic_icon.gif' [static]

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 162 of file test_attopic.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 158 of file test_attopic.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 161 of file test_attopic.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 159 of file test_attopic.py.

Reimplemented from ATContentTypes.tests.atcttestcase.ATCTTypeTestCase.

Definition at line 160 of file test_attopic.py.


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