Can't create an ATTopic using invokeFactory in ftest
Derek Richardson
derek.richardson at gatech.edu
Sun Jul 29 18:31:04 UTC 2007
fschulze resolved the problem for me. Turns out the implicit user in tests in
not a Manager. Adding:
self.setRoles(['Manager']
before creating the Topic solved the problem. Sorry for the noise!
Derek
Derek Richardson wrote:
> The following ftest fails in 3.0 rc1:
>
>
> # Start test case
>
> from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
> from Products.PloneTestCase.PloneTestCase import setupPloneSite
> setupPloneSite()
>
> class TestTopic(FunctionalTestCase):
> def testCreate(self):
> self.portal.error_log._ignored_exceptions = ()
> self.folder.invokeFactory('Topic', 'fooTopic', name='fooTopic')
>
> def test_suite():
> from unittest import TestSuite, makeSuite
> suite = TestSuite()
> suite.addTest(makeSuite(TestTopic
>
> # end test case
>
> I'm doing this like I've seen it done in other packages. I get the
> following traceback:
>
>
> Error in test testCreate
> (plone.app.syndication.outbound.tests.testTopic.TestTopic)
> Traceback (most recent call last):
> File
> "/Users/dkr/zope-insts/vice/parts/zope2/lib/python/Testing/ZopeTestCase/profiler.py",
> line 98, in __call__
> testMethod()
> File
> "/Users/dkr/zope-insts/vice/src/plone.app.syndication.outbound/plone/app/syndication/outbound/tests/testTopic.py",
> line 7, in testCreate
> self.folder.invokeFactory('Topic', 'fooTopic', name='fooTopic')
> File
> "/Users/dkr/zope-insts/vice/parts/plone/ATContentTypes/lib/constraintypes.py",
> line 281, in invokeFactory
> RESPONSE=None, *args, **kw)
> File "/Users/dkr/zope-insts/vice/parts/plone/CMFCore/PortalFolder.py",
> line 311, in invokeFactory
> return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
> File "/Users/dkr/zope-insts/vice/parts/plone/CMFCore/TypesTool.py",
> line 716, in constructContent
> ob = info.constructInstance(container, id, *args, **kw)
> File "/Users/dkr/zope-insts/vice/parts/plone/CMFCore/TypesTool.py",
> line 274, in constructInstance
> raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
> Unauthorized: Cannot create Topic
>
> I am surprised to get an Unauthorized error when directly manipulating
> the zodb in a functional test. I have verbose security on. But I get no
> additional info.
>
> Any hints appreciated!
>
> Derek
More information about the Product-Developers
mailing list