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
begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[email protected]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers