-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Charlie Clark wrote: > Hi, > > I'm having a little trouble with writing the tests for my formlib > folder contents view replacement. The basic tests (based on yuppie's > doctests) are fine but incomplete. I'm now integrating batching and am > getting caught on view permissions for DummyContent objects. > > This is the test: > > def _make_batch(self): > from Products.CMFCore.tests.base.dummy import DummyContent > batch_size = 25 > for i in range(batch_size + 2): > content_id = "Dummy%s" % i > content_obj = DummyContent(content_id) > content_obj.portal_type = "Dummy Content" > obj = self.folder._setObject(content_id, content_obj) > content_obj.manage_setLocalRoles('user_foo', ['Owner']) > > def test_check_batching(self): > self._make_batch() > batch_size = 25 > view = ContentsView(self.folder, TestRequest()) > self.assertEquals(view._getBatchObj().sequence_length, > batch_size) > self.assertEquals(view.navigation_next['title'], "NEXT N > ITEMS") > > and this is error: > > File "/Users/charlieclark/cmf-svn/CMF.buildout/trunk/src/Zope2/src/ > AccessControl/ZopeGuards.py", line 71, in guarded_getitem > if getSecurityManager().validate(object, object, None, v): > Unauthorized: (item 0): You are not allowed to access 'Dummy0' in this > context > > Obviously I don't have the permission to access my newly created > objects. So how do I go about fixing this for my tests? I can't find a > comparable example in the rest of the CMF tests? Is it best to fix the > permissions of the objects so that are viewable be "anonymous" or > should I assign my view to my user? And while I'm at it, am I creating > my dummy objects in the right way? I remember Tres saying something > about this recently.
Do you need to set up a security manager with 'user_foo', grep for 'newSecurityManager' in other CMF tests. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFKK7uJ+gerLs4ltQ4RAuETAJ4k+2UXnme76ex4th3wvkp5IgqyJgCdE5Us w4dVMlK3UgdZBMrZlmt7yyQ= =/E3e -----END PGP SIGNATURE----- _______________________________________________ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests