[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests - test_nextservice.py:1.8 test_servicemanagercontainer.py:1.8

Jim Fulton jim at zope.com
Tue Sep 2 17:47:17 EDT 2003


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

Modified Files:
	test_nextservice.py test_servicemanagercontainer.py 
Log Message:
Added ISite, which is a marker interface indicating that an object is
a site.

When an object is made into a site, ISite is declared for it.

Change to test whether something is a site by testing whether 
it (declares it) implements ISite.


=== Zope3/src/zope/app/component/tests/test_nextservice.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/component/tests/test_nextservice.py:1.7	Thu Jun  5 08:03:15 2003
+++ Zope3/src/zope/app/component/tests/test_nextservice.py	Tue Sep  2 16:46:45 2003
@@ -18,31 +18,29 @@
 from unittest import TestCase, main, makeSuite
 from zope.app.component.hooks import getServiceManager_hook
 from zope.app.component.nextservice import getNextServiceManager
-from zope.app.interfaces.services.service import IServiceManagerContainer
+from zope.app.interfaces.services.service import IPossibleSite, ISite
 from zope.app.traversing import IContainmentRoot
 from zope.component.exceptions import ComponentLookupError
 from zope.component.interfaces import IServiceService
 from zope.component.service import serviceManager
 from zope.context import Wrapper
-from zope.interface import implements
+from zope.interface import implements, directlyProvides
 
 
 class ServiceManager:
     implements(IServiceService)
 
 class Folder:
-    implements(IServiceManagerContainer)
+    implements(IPossibleSite)
 
     sm = None
 
-    def getServiceManager(self, default=None):
+    def getSiteManager(self, default=None):
         return self.sm
 
-    def hasServiceManager(self):
-        return self.sm
-
-    def setServiceManager(self, sm):
+    def setSiteManager(self, sm):
         self.sm = sm
+        directlyProvides(self, ISite)
 
 class Root(Folder):
     implements(IContainmentRoot)
@@ -56,11 +54,11 @@
 
         f1 = Wrapper(Folder(), root)
         sm1 = ServiceManager()
-        f1.setServiceManager(sm1)
+        f1.setSiteManager(sm1)
 
         f2 = Wrapper(Folder(), f1)
         sm2 = ServiceManager()
-        f2.setServiceManager(sm2)
+        f2.setSiteManager(sm2)
 
         self.root = root
         self.f1 = f1
@@ -88,7 +86,7 @@
         root = Folder()
         f1 = Wrapper(Folder(), root)
         sm1 = ServiceManager()
-        f1.setServiceManager(sm1)
+        f1.setSiteManager(sm1)
         self.assertRaises(TypeError,
                           getNextServiceManager, Wrapper(sm1, f1)
                           )


=== Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py:1.7	Sat Jun  7 02:37:21 2003
+++ Zope3/src/zope/app/component/tests/test_servicemanagercontainer.py	Tue Sep  2 16:46:45 2003
@@ -19,7 +19,7 @@
 
 from unittest import TestCase, main, makeSuite
 from zope.component.interfaces import IServiceService
-from zope.app.interfaces.services.service import IServiceManagerContainer
+from zope.app.interfaces.services.service import IPossibleSite, ISite
 from zope.component.exceptions import ComponentLookupError
 from zope.interface.verify import verifyObject
 from zope.context import getbaseobject
@@ -55,28 +55,21 @@
     arguments and that returns a new service manager
     container that has no service manager."""
 
-    def testIServiceManagerContainerVerify(self):
-        verifyObject(IServiceManagerContainer, self.makeTestObject())
+    def test_IPossibleSite_verify(self):
+        verifyObject(IPossibleSite, self.makeTestObject())
 
-    def testHas(self):
-        smc=self.makeTestObject()
-        self.failIf(smc.hasServiceManager())
-        smc.setServiceManager(ServiceManager())
-        self.failUnless(smc.hasServiceManager())
-
-    def testGet(self):
-        smc=self.makeTestObject()
-        # since the managers are now wrapped, need to look at base object
-        self.failUnless(getbaseobject(smc.queryServiceManager()) is None)
-        self.assertRaises(ComponentLookupError, smc.getServiceManager)
-        sm=ServiceManager()
-        smc.setServiceManager(sm)
-        self.failUnless(getbaseobject(smc.getServiceManager()) is sm)
-        self.failUnless(getbaseobject(smc.queryServiceManager(self)) is sm)
+    def test_get_and_set(self):
+        smc = self.makeTestObject()
+        self.failIf(ISite.isImplementedBy(smc))
+        sm = ServiceManager()
+        smc.setSiteManager(sm)
+        self.failUnless(ISite.isImplementedBy(smc))
+        self.failUnless(getbaseobject(smc.getSiteManager()) is sm)
+        verifyObject(ISite, smc)
 
-    def testSet(self):
+    def test_set_w_bogus_value(self):
         smc=self.makeTestObject()
-        self.assertRaises(Exception, smc.setServiceManager, self)
+        self.assertRaises(Exception, smc.setSiteManager, self)
 
 
 




More information about the Zope3-Checkins mailing list