Re: [Zope-dev] ZopeTestCase and interactions

2009-07-28 Thread Hanno Schlichting
On Mon, Jul 27, 2009 at 2:57 AM, Martin Aspelioptilude+li...@gmail.com wrote:
 Hanno Schlichting wrote:
 The ZopeTestCase classes themselves don't set up any of the ZCML
 structure right now and I'd like to keep it that way.

 True. This isn't a ZCML, thing, though. :)

The thread local itself is not. But without the permission utilities
being registered you don't get very far.

 Isn't the placeless layer exactly for this use-case of getting some
 minimal integration fixture set up? Since Zope 2.12 a Zope2 specific
 version of that is in Testing.ZopeTestCase.placeless. Before you would
 get it from zope.app.testing.placelesssetup.

 I see. That sounds like a sensible place. My main aim is that when you
 use a PloneTestCase, you should get the interaction set up so that calls
 to zope.security.checkPermission() don't fail. Does PTC and other
 similar things set up the placeless layer? Or something like it?

So far nothing sets up the interaction as far as I know.

I tried talking Stefan into having a look at this mess ;-)

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] ZopeTestCase and interactions

2009-07-26 Thread Martin Aspeli
Hi,

It seems that an integration test written using ZopeTestCase (and 
PloneTestCase) does not support using zope.security.checkPermission().

The problem is that the interaction threadlocal isn't set up, so you get 
an AttributeError.

It's easy to fix: just call Products.Five.security.newInteraction() 
before the test is run.

Is this something that should go into ZopeTestCase's setUp()?

Cheers,
Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] ZopeTestCase and interactions

2009-07-26 Thread Hanno Schlichting
On Sun, Jul 26, 2009 at 5:21 PM, Martin Aspelioptilude+li...@gmail.com wrote:
 The problem is that the interaction threadlocal isn't set up, so you get
 an AttributeError.

 It's easy to fix: just call Products.Five.security.newInteraction()
 before the test is run.

 Is this something that should go into ZopeTestCase's setUp()?

The ZopeTestCase classes themselves don't set up any of the ZCML
structure right now and I'd like to keep it that way.

Isn't the placeless layer exactly for this use-case of getting some
minimal integration fixture set up? Since Zope 2.12 a Zope2 specific
version of that is in Testing.ZopeTestCase.placeless. Before you would
get it from zope.app.testing.placelesssetup.

The module in Testing.ZopeTestCase uses from zope.security.management
import newInteraction though and not Five. Maybe it should use the
Five version instead?

Hanno
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] ZopeTestCase and interactions

2009-07-26 Thread Martin Aspeli
Hanno Schlichting wrote:
 On Sun, Jul 26, 2009 at 5:21 PM, Martin Aspelioptilude+li...@gmail.com 
 wrote:
 The problem is that the interaction threadlocal isn't set up, so you get
 an AttributeError.

 It's easy to fix: just call Products.Five.security.newInteraction()
 before the test is run.

 Is this something that should go into ZopeTestCase's setUp()?
 
 The ZopeTestCase classes themselves don't set up any of the ZCML
 structure right now and I'd like to keep it that way.

True. This isn't a ZCML, thing, though. :)

 Isn't the placeless layer exactly for this use-case of getting some
 minimal integration fixture set up? Since Zope 2.12 a Zope2 specific
 version of that is in Testing.ZopeTestCase.placeless. Before you would
 get it from zope.app.testing.placelesssetup.

I see. That sounds like a sensible place. My main aim is that when you 
use a PloneTestCase, you should get the interaction set up so that calls 
to zope.security.checkPermission() don't fail. Does PTC and other 
similar things set up the placeless layer? Or something like it?

 The module in Testing.ZopeTestCase uses from zope.security.management
 import newInteraction though and not Five. Maybe it should use the
 Five version instead?

Almost certainly.

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )