[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests -
test_contentdirective.py:1.11.18.2 test_factory.py:1.8.18.2
test_servicedirective.py:1.11.18.2
Marius Gedminas
marius at pov.lt
Fri Mar 19 13:51:24 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/component/tests
In directory cvs.zope.org:/tmp/cvs-serv26650/src/zope/app/component/tests
Modified Files:
Tag: mgedmin-events2-branch
test_contentdirective.py test_factory.py
test_servicedirective.py
Log Message:
Added IParticipation and replaced the lists of principals in IInteraction with
a list of participations. Made BaseRequest an IParticipation and replaced
request.user with request.principal everywhere.
=== Zope3/src/zope/app/component/tests/test_contentdirective.py 1.11.18.1 => 1.11.18.2 ===
--- Zope3/src/zope/app/component/tests/test_contentdirective.py:1.11.18.1 Mon Mar 8 13:43:36 2004
+++ Zope3/src/zope/app/component/tests/test_contentdirective.py Fri Mar 19 13:50:45 2004
@@ -26,7 +26,7 @@
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.security.management import system_user
-from zope.security.management import newInteraction, getInteraction
+from zope.security.management import newInteraction
from zope.security.proxy import Proxy
from zope.app.security.exceptions import UndefinedPermissionError
from zope.component import getService
@@ -39,6 +39,13 @@
from zope.app.component.tests.exampleclass import IExample, IExample2
+class ParticipationStub:
+
+ def __init__(self, principal):
+ self.principal = principal
+ self.interaction = None
+
+
def configfile(s):
return StringIO("""<configure
xmlns='http://namespaces.zope.org/zope'
@@ -50,8 +57,7 @@
class TestContentDirective(PlacelessSetup, unittest.TestCase):
def setUp(self):
super(TestContentDirective, self).setUp()
- newInteraction(None)
- getInteraction().add(system_user)
+ newInteraction(ParticipationStub(system_user))
XMLConfig('meta.zcml', zope.app.component)()
XMLConfig('meta.zcml', zope.app.security)()
@@ -138,8 +144,7 @@
class TestFactorySubdirective(PlacelessSetup, unittest.TestCase):
def setUp(self):
super(TestFactorySubdirective, self).setUp()
- newInteraction(None)
- getInteraction().add(system_user)
+ newInteraction(ParticipationStub(system_user))
XMLConfig('meta.zcml', zope.app.component)()
XMLConfig('meta.zcml', zope.app.security)()
=== Zope3/src/zope/app/component/tests/test_factory.py 1.8.18.1 => 1.8.18.2 ===
--- Zope3/src/zope/app/component/tests/test_factory.py:1.8.18.1 Mon Mar 8 13:43:36 2004
+++ Zope3/src/zope/app/component/tests/test_factory.py Fri Mar 19 13:50:45 2004
@@ -20,8 +20,7 @@
from zope.configuration.xmlconfig import XMLConfig
from zope.app.services.servicenames import Factories
from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.security.management import system_user
-from zope.security.management import newInteraction, getInteraction
+from zope.security.management import newInteraction, system_user
import zope.configuration
import zope.app.security
@@ -29,6 +28,14 @@
from zope.app.component.tests.exampleclass import ExampleClass
+
+class ParticipationStub:
+
+ def __init__(self, principal):
+ self.principal = principal
+ self.interaction = None
+
+
def configfile(s):
return StringIO("""<configure
xmlns='http://namespaces.zope.org/zope'
@@ -40,8 +47,7 @@
class Test(PlacelessSetup, unittest.TestCase):
def setUp(self):
super(Test, self).setUp()
- newInteraction(None)
- getInteraction().add(system_user)
+ newInteraction(ParticipationStub(system_user))
XMLConfig('meta.zcml', zope.app.component)()
XMLConfig('meta.zcml', zope.app.security)()
=== Zope3/src/zope/app/component/tests/test_servicedirective.py 1.11.18.1 => 1.11.18.2 ===
--- Zope3/src/zope/app/component/tests/test_servicedirective.py:1.11.18.1 Mon Mar 8 13:43:36 2004
+++ Zope3/src/zope/app/component/tests/test_servicedirective.py Fri Mar 19 13:50:45 2004
@@ -26,6 +26,14 @@
from zope.component import getService
from zope.app.tests.placelesssetup import PlacelessSetup
+
+class ParticipationStub:
+
+ def __init__(self, principal):
+ self.principal = principal
+ self.interaction = None
+
+
template = """<configure
xmlns='http://namespaces.zope.org/zope'
xmlns:test='http://www.zope.org/NS/Zope3/test'
@@ -178,8 +186,7 @@
# Need to "log someone in" to turn on checks
from zope.security.management import newInteraction, getInteraction
- newInteraction(None)
- getInteraction().add('someuser')
+ newInteraction(ParticipationStub('someuser'))
service = getService(None, "Foo")
# simulate untrusted code!
@@ -190,9 +197,9 @@
self.assertRaises(Forbidden, getattr, service, 'bar')
-
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
+
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())
More information about the Zope3-Checkins
mailing list