[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests -
iregistry.py:1.2 registrationstack.py:1.4
test_nameregistry.py:1.2 test_registered.py:1.2
test_registrationstatusproperty.py:1.4
Jim Fulton
jim at zope.com
Sun Sep 21 13:31:44 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv12774/src/zope/app/services/tests
Modified Files:
iregistry.py registrationstack.py test_nameregistry.py
test_registered.py test_registrationstatusproperty.py
Log Message:
No-longer use context wrappers.
=== Zope3/src/zope/app/services/tests/iregistry.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/services/tests/iregistry.py:1.1 Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/iregistry.py Sun Sep 21 13:31:13 2003
@@ -19,7 +19,6 @@
"""
from zope.app.interfaces.services.registration import IRegistry
from zope.interface.verify import verifyObject
-from zope.context import getWrapperContainer
class TestingIRegistry:
"""Base class for testing implementors of IRegistry
@@ -44,8 +43,8 @@
have some context.
"""
- self.assertEqual(getWrapperContainer(ob), parent)
- self.failIf(getWrapperContainer(getWrapperContainer(ob)) is None)
+ self.assertEqual(ob.__parent__, parent)
+ self.failIf(ob.__parent__.__parent__ is None)
def test_implements_IRegistry(self):
verifyObject(IRegistry, self.createTestingRegistry())
@@ -64,7 +63,7 @@
registration = self.createTestingRegistration()
stack = registry.createRegistrationsFor(registration)
- self.assertEqual(getWrapperContainer(stack), registry)
+ self.assertEqual(stack.__parent__, registry)
# If we call it again, we should get the same object
self.assertEqual(registry.createRegistrationsFor(registration),
=== Zope3/src/zope/app/services/tests/registrationstack.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/tests/registrationstack.py:1.3 Wed Jul 2 17:37:54 2003
+++ Zope3/src/zope/app/services/tests/registrationstack.py Sun Sep 21 13:31:13 2003
@@ -13,10 +13,11 @@
##############################################################################
from zope.app.services.registration import RegistrationStatusProperty
+from zope.app.container.contained import Contained
__metaclass__ = type
-class TestingRegistration:
+class TestingRegistration(Contained):
status = RegistrationStatusProperty()
def __init__(self, id):
=== Zope3/src/zope/app/services/tests/test_nameregistry.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/services/tests/test_nameregistry.py:1.1 Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/test_nameregistry.py Sun Sep 21 13:31:13 2003
@@ -20,8 +20,6 @@
from zope.app.services.registration import NameRegistry
from zope.app.services.registration import NameComponentRegistry
-from zope.app.context import ContextWrapper
-from zope.context import getWrapperContainer
class RegistrationStub:
@@ -49,7 +47,8 @@
def setUp(self):
self.container = object()
- self.subject = ContextWrapper(NameRegistry(), self.container)
+ self.subject = NameRegistry()
+ self.subject.__parent__ = self.container
def test_queryRegistrationsFor(self):
subject = self.subject
@@ -57,12 +56,11 @@
self.assertEquals(subject.queryRegistrationsFor(cfg), None)
self.assertEquals(subject.queryRegistrationsFor(cfg, 42), 42)
- registry = RegistryStub()
- subject._bindings["Foo"] = registry
+ registry = subject.createRegistrations("Foo")
result = subject.queryRegistrationsFor(cfg)
self.assertEquals(result, registry)
- self.assertEquals(getWrapperContainer(result), subject)
- self.assertEquals(getWrapperContainer(getWrapperContainer(result)),
+ self.assertEquals(result.__parent__, subject)
+ self.assertEquals(result.__parent__.__parent__,
self.container)
def test_queryRegistrations(self):
@@ -70,13 +68,11 @@
self.assertEquals(subject.queryRegistrations("Foo"), None)
self.assertEquals(subject.queryRegistrations("Foo", 42), 42)
- registry = RegistryStub()
- subject._bindings["Foo"] = registry
+ registry = subject.createRegistrations("Foo")
result = subject.queryRegistrations("Foo")
self.assertEquals(result, registry)
- self.assertEquals(getWrapperContainer(result), subject)
- self.assertEquals(getWrapperContainer(getWrapperContainer(result)),
- self.container)
+ self.assertEquals(result.__parent__, subject)
+ self.assertEquals(result.__parent__.__parent__, self.container)
def test_createRegistrationsFor(self):
subject = self.subject
@@ -89,9 +85,8 @@
self.assertNotEquals(r1, r2)
self.assertNotEquals(r2, r3)
self.assertEquals(r3, subject._bindings['Foo'])
- self.assertEquals(getWrapperContainer(r3), subject)
- self.assertEquals(getWrapperContainer(getWrapperContainer(r3)),
- self.container)
+ self.assertEquals(r3.__parent__, subject)
+ self.assertEquals(r3.__parent__.__parent__, self.container)
self.failUnless(subject._p_changed)
def test_createRegistrations(self):
@@ -103,9 +98,8 @@
self.assertNotEquals(r1, r2)
self.assertNotEquals(r2, r3)
self.assertEquals(r3, subject._bindings['Foo'])
- self.assertEquals(getWrapperContainer(r3), subject)
- self.assertEquals(getWrapperContainer(getWrapperContainer(r3)),
- self.container)
+ self.assertEquals(r3.__parent__, subject)
+ self.assertEquals(r3.__parent__.__parent__, self.container)
self.failUnless(subject._p_changed)
def test_listRegistrationNames(self):
@@ -120,8 +114,8 @@
def setUp(self):
self.container = object()
- self.subject = ContextWrapper(NameComponentRegistry(),
- self.container)
+ self.subject = NameComponentRegistry()
+ self.subject.__parent__ = self.container
def test_queryActiveComponent(self):
subject = self.subject
=== Zope3/src/zope/app/services/tests/test_registered.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/services/tests/test_registered.py:1.1 Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/test_registered.py Sun Sep 21 13:31:13 2003
@@ -20,8 +20,9 @@
from zope.app.interfaces.annotation import IAnnotations
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.interface import implements
+from zope.app.container.contained import Contained
-class C(dict):
+class C(dict, Contained):
implements(IAnnotations)
class TestRegistered(PlacelessSetup, TestCase):
@@ -66,9 +67,7 @@
self.assertEqual(obj.usages(), ())
def test_suite():
- return TestSuite((
- makeSuite(TestRegistered),
- ))
+ return makeSuite(TestRegistered)
if __name__=='__main__':
main(defaultTest='test_suite')
=== Zope3/src/zope/app/services/tests/test_registrationstatusproperty.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/tests/test_registrationstatusproperty.py:1.3 Tue Sep 2 16:46:51 2003
+++ Zope3/src/zope/app/services/tests/test_registrationstatusproperty.py Sun Sep 21 13:31:13 2003
@@ -26,11 +26,10 @@
from zope.app.interfaces.services.registration import RegisteredStatus
from zope.app.interfaces.services.registration import UnregisteredStatus
from zope.app.interfaces.services.registration import ActiveStatus
-from zope.app.context import ContextWrapper
from zope.component.exceptions import ComponentLookupError
from zope.app.interfaces.services.registration import NoLocalServiceError
from zope.interface import implements
-
+from zope.app.container.contained import contained
class TestingRegistration(TestingRegistration):
serviceType = "Services"
@@ -89,7 +88,7 @@
def test_property(self):
- configa = ContextWrapper(TestingRegistration('a'), self.rootFolder)
+ configa = contained(TestingRegistration('a'), self.rootFolder)
self.assertEqual(configa.status, UnregisteredStatus)
configa.status = RegisteredStatus
@@ -100,7 +99,7 @@
self.assertEqual(self.__sm.registry._data, ('a', ))
self.assertEqual(configa.status, ActiveStatus)
- configb = ContextWrapper(TestingRegistration('b'), self.rootFolder)
+ configb = contained(TestingRegistration('b'), self.rootFolder)
self.assertEqual(self.__sm.registry._data, ('a', ))
self.assertEqual(configb.status, UnregisteredStatus)
@@ -108,7 +107,7 @@
self.assertEqual(self.__sm.registry._data, ('a', 'b'))
self.assertEqual(configb.status, RegisteredStatus)
- configc = ContextWrapper(TestingRegistration('c'), self.rootFolder)
+ configc = contained(TestingRegistration('c'), self.rootFolder)
self.assertEqual(configc.status, UnregisteredStatus)
self.assertEqual(self.__sm.registry._data, ('a', 'b'))
@@ -134,7 +133,7 @@
# now the ConnectionRegistration.status cannot access the
# SQLConnectionService
- configa = ContextWrapper(PassiveRegistration('a'), self.rootFolder)
+ configa = contained(PassiveRegistration('a'), self.rootFolder)
self.assertEqual(configa.status, UnregisteredStatus)
try:
@@ -155,7 +154,7 @@
# we should also get an error if there *is a matching service,
# not it is non-local
- configa = ContextWrapper(UtilityRegistration('a'), self.rootFolder)
+ configa = contained(UtilityRegistration('a'), self.rootFolder)
self.assertEqual(configa.status, UnregisteredStatus)
try:
More information about the Zope3-Checkins
mailing list