[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests - service.py:1.2.26.1 test_directives.py:1.5.2.1 test_factory.py:1.1.4.1 test_nextservice.py:1.5.10.1 test_requirepermissions.py:1.1.4.1 test_servicemanagercontainer.py:1.5.10.1

Grégoire Weber zope@i-con.ch
Sun, 22 Jun 2003 10:23:55 -0400


Update of /cvs-repository/Zope3/src/zope/app/component/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/component/tests

Modified Files:
      Tag: cw-mail-branch
	service.py test_directives.py test_factory.py 
	test_nextservice.py test_requirepermissions.py 
	test_servicemanagercontainer.py 
Log Message:
Synced up with HEAD

=== Zope3/src/zope/app/component/tests/service.py 1.2 => 1.2.26.1 ===
--- Zope3/src/zope/app/component/tests/service.py:1.2	Wed Dec 25 09:12:46 2002
+++ Zope3/src/zope/app/component/tests/service.py	Sun Jun 22 10:22:55 2003
@@ -17,7 +17,7 @@
 """
 __metaclass__ = type # All classes are new style when run with Python 2.2+
 
-from zope.interface import Interface
+from zope.interface import Interface, implements
 
 class IFooService(Interface):
 
@@ -26,7 +26,7 @@
 
 class FooService:
 
-    __implements__ = IFooService
+    implements(IFooService)
 
     def foo(self): return "foo here"
     def foobar(self): return "foobarred"


=== Zope3/src/zope/app/component/tests/test_directives.py 1.5 => 1.5.2.1 ===
--- Zope3/src/zope/app/component/tests/test_directives.py:1.5	Wed May 21 16:29:10 2003
+++ Zope3/src/zope/app/component/tests/test_directives.py	Sun Jun 22 10:22:55 2003
@@ -19,7 +19,8 @@
 from zope.configuration.exceptions import ConfigurationError
 from zope.app.security.exceptions import UndefinedPermissionError
 
-from zope.security.proxy import getTestProxyItems, getObject as proxiedObject
+from zope.proxy import getProxiedObject
+from zope.security.proxy import getTestProxyItems
 
 import zope.app.component
 from zope.component.exceptions import ComponentLookupError
@@ -33,6 +34,7 @@
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.component.tests.views import IV, IC, V1, VZMI, R1, RZMI
 from zope.component.tests.request import Request
+from zope.interface import implements
 
 
 template = """<zopeConfigure
@@ -42,7 +44,7 @@
    </zopeConfigure>"""
 
 class Ob:
-    __implements__ = IC
+    implements(IC)
 
 def definePermissions():
     XMLConfig('meta.zcml', zope.app.component)()
@@ -122,7 +124,7 @@
         adapter = getAdapter(Content(), IApp)
         items = [item[0] for item in getTestProxyItems(adapter)]
         self.assertEqual(items, ['a', 'f'])
-        self.assertEqual(proxiedObject(adapter).__class__, Comp)
+        self.assertEqual(getProxiedObject(adapter).__class__, Comp)
 
     def testAdapterUndefinedPermission(self):
         config = StringIO(template % (
@@ -215,7 +217,7 @@
         utility = getUtility(None, IApp)
         items = [item[0] for item in getTestProxyItems(utility)]
         self.assertEqual(items, ['a', 'f'])
-        self.assertEqual(proxiedObject(utility), comp)
+        self.assertEqual(getProxiedObject(utility), comp)
 
     def testUtilityUndefinedPermission(self):
         config = StringIO(template % (


=== Zope3/src/zope/app/component/tests/test_factory.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/component/tests/test_factory.py:1.1	Mon May 12 12:32:40 2003
+++ Zope3/src/zope/app/component/tests/test_factory.py	Sun Jun 22 10:22:55 2003
@@ -46,7 +46,7 @@
 
     def testFactory(self):
         from zope.component import getService
-        from zope.proxy.introspection import removeAllProxies
+        from zope.proxy import removeAllProxies
         f = configfile("""
 <permission id="zope.Foo" title="Zope Foo Permission" />
 <content class="zope.app.component.tests.exampleclass.ExampleClass">
@@ -65,7 +65,7 @@
 
     def testFactoryDefaultId(self):
         from zope.component import getService
-        from zope.proxy.introspection import removeAllProxies
+        from zope.proxy import removeAllProxies
         f = configfile("""
 <permission id="zope.Foo" title="Zope Foo Permission" />
 <content class="zope.app.component.tests.exampleclass.ExampleClass">


=== Zope3/src/zope/app/component/tests/test_nextservice.py 1.5 => 1.5.10.1 ===
--- Zope3/src/zope/app/component/tests/test_nextservice.py:1.5	Thu May  1 15:35:08 2003
+++ Zope3/src/zope/app/component/tests/test_nextservice.py	Sun Jun 22 10:22:55 2003
@@ -23,14 +23,15 @@
 from zope.component.exceptions import ComponentLookupError
 from zope.component.interfaces import IServiceService
 from zope.component.service import serviceManager
-from zope.proxy.context import Wrapper
+from zope.context import Wrapper
+from zope.interface import implements
 
 
 class ServiceManager:
-    __implements__ =  IServiceService
+    implements(IServiceService)
 
 class Folder:
-    __implements__ =  IServiceManagerContainer
+    implements(IServiceManagerContainer)
 
     sm = None
 
@@ -44,36 +45,44 @@
         self.sm = sm
 
 class Root(Folder):
-    __implements__ =  IServiceManagerContainer, IContainmentRoot
-
-root = Root()
-
-f1 = Wrapper(Folder(), root)
-sm1 = ServiceManager()
-f1.setServiceManager(sm1)
-
-f2 = Wrapper(Folder(), f1)
-sm2 = ServiceManager()
-f2.setServiceManager(sm2)
-
+    implements(IContainmentRoot)
 
 
 class Test(TestCase):
 
+    def setUp(self):
+        TestCase.setUp(self)
+        root = Root()
+
+        f1 = Wrapper(Folder(), root)
+        sm1 = ServiceManager()
+        f1.setServiceManager(sm1)
+
+        f2 = Wrapper(Folder(), f1)
+        sm2 = ServiceManager()
+        f2.setServiceManager(sm2)
+
+        self.root = root
+        self.f1 = f1
+        self.f2 = f2
+        self.sm1 = sm1
+        self.sm2 = sm2
+
     def test_getServiceManager(self):
 
-        self.assertEqual(getServiceManager_hook(root), serviceManager)
-        self.assertEqual(getServiceManager_hook(f1), sm1)
-        self.assertEqual(getServiceManager_hook(f2), sm2)
+        self.assertEqual(getServiceManager_hook(self.root), serviceManager)
+        self.assertEqual(getServiceManager_hook(self.f1), self.sm1)
+        self.assertEqual(getServiceManager_hook(self.f2), self.sm2)
 
     def test_getNextServiceManager(self):
 
         self.assertRaises(ComponentLookupError,
-                          getNextServiceManager, root)
+                          getNextServiceManager, self.root)
 
-        self.assertEqual(getNextServiceManager(Wrapper(sm1, f1)),
+        self.assertEqual(getNextServiceManager(Wrapper(self.sm1, self.f1)),
                          serviceManager)
-        self.assertEqual(getNextServiceManager(Wrapper(sm2, f2)), sm1)
+        self.assertEqual(getNextServiceManager(Wrapper(self.sm2, self.f2)),
+                         self.sm1)
 
     def test_getNextServiceManager_fails_w_bad_root(self):
         root = Folder()


=== Zope3/src/zope/app/component/tests/test_requirepermissions.py 1.1 => 1.1.4.1 ===
--- Zope3/src/zope/app/component/tests/test_requirepermissions.py:1.1	Mon May 12 12:32:40 2003
+++ Zope3/src/zope/app/component/tests/test_requirepermissions.py	Sun Jun 22 10:22:55 2003
@@ -22,6 +22,7 @@
 import zope.app.component
 import zope.app.security
 import zope.configuration
+from zope.interface import implements
 
 # So we can use config parser to exercise protectClass stuff.
 from zope.configuration.xmlconfig import XMLConfig
@@ -56,7 +57,7 @@
             def m2(self):
                 return "m2"
         class C(B):
-            __implements__ = module.I
+            implements(module.I)
             def m3(self):
                 return "m3"
             def m4(self):


=== Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py 1.5 => 1.5.10.1 ===
--- Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py:1.5	Thu May  1 15:35:08 2003
+++ Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py	Sun Jun 22 10:22:55 2003
@@ -22,11 +22,12 @@
 from zope.app.interfaces.services.service import IServiceManagerContainer
 from zope.component.exceptions import ComponentLookupError
 from zope.interface.verify import verifyObject
-from zope.proxy.context import getbaseobject
+from zope.context import getbaseobject
+from zope.interface import implements
 
 class ServiceManager:
 
-    __implements__ =  IServiceService
+    implements(IServiceService)
 
     ############################################################
     # Implementation methods for interface