[Product-Developers] Problem with PTC test setup

Andreas Jung lists at zopyx.com
Fri Jun 12 15:39:28 UTC 2009


Hi there,

currently writing tests for vs.event - an AT-derived event type for Plone.
The code works perfectly in reality but the tests don't.

This is the test setup (everything is straight-forward):

import vs.event

PloneTestCase.installProduct('vs.event')
PloneTestCase.setupPloneSite(products=('vs.event', ),
                             extension_profiles=('vs.event:default',))


class VSEventTest(PloneTestCase.PloneTestCase):

    def afterSetUp(self):
        ZopeTestCase.utils.setupCoreSessions(self.app)
        zcml.load_config('configure.zcml', vs.event)
        self.membership = self.portal.portal_membership
        self.membership.addMember('god', 'secret', ['Manager'], [])


    def testCreateEvent(self):
        self.login('god')
        user = getSecurityManager().getUser()
        self.assertEqual('Manager' in user.getRoles(), True)
        self.portal.invokeFactory('VSEvent', id='foo')

However invokeFactory() fails (although I am Manager):

  File
"/data/develop/repository/ext1.svn.banality.de/vs.event/buildout/trunk/src/vs.event/vs/event/tests.py",
line 42, in testCreateEvent
    self.portal.invokeFactory('VSEvent', id='foo')
  File
"/data/develop/repository/ext1.svn.banality.de/vs.event/buildout/trunk/parts/plone/CMFCore/PortalFolder.py",
line 315, in invokeFactory
    return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
  File
"/data/develop/repository/ext1.svn.banality.de/vs.event/buildout/trunk/parts/plone/CMFCore/TypesTool.py",
line 717, in constructContent
    ob = info.constructInstance(container, id, *args, **kw)
  File
"/data/develop/repository/ext1.svn.banality.de/vs.event/buildout/trunk/parts/plone/CMFCore/TypesTool.py",
line 274, in constructInstance
    raise AccessControl_Unauthorized('Cannot create %s' % self.getId())
Unauthorized: Cannot create VSEvent


Somehow isConstructionAllowed is making the problem:

..>
/data/develop/repository/ext1.svn.banality.de/vs.event/buildout/trunk/parts/plone/CMFCore/TypesTool.py(415)isConstructionAllowed()
-> if self.product:
(Pdb) args
self = <DynamicViewTypeInformation at VSEvent>
container = <PloneSite at plone>
(Pdb) print self

The FTI for VSEvent also looks fine to me:

(Pdb) pp self.__dict__
{'__ac_local_roles__': {'portal_owner': ['Owner']},
 '_actions': (<ActionInformation at view>,
              <ActionInformation at edit>,
              <ActionInformation at references>,
              <ActionInformation at ics>,
              <ActionInformation at vcs>,
              <ActionInformation at history>,
              <ActionInformation at external_edit>),
 '_aliases': {'(Default)': '(dynamic view)',
              'edit': 'atct_edit',
              'sharing': '@@sharing',
              'view': '(selected layout)'},
 'allow_discussion': False,
 'allowed_content_types': (),
 'content_icon': 'event_icon.gif',
 'content_meta_type': 'VSEvent',
 'default_view': 'vs_event_view',
 'description': 'Information about an upcoming event, which can be
displayed in the calendar.',
 'factory': 'addVSEvent',
 'filter_content_types': True,
 'global_allow': True,
 'i18n_domain': 'vs.event',
 'id': 'VSEvent',
 'immediate_view': 'vs_event_view',
 'product': 'vs.event',
 'title': 'VSEvent',
 'view_methods': ('vs_event_view',)}

Somehow the factory 'addVSEvent' can not be obtained.
Am I missing something in my test setup?

Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 316 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20090612/4f3b8962/attachment.vcf>


More information about the Product-Developers mailing list