[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests - testAdder.py:1.1.2.4 testBindings.py:1.1.2.6

Gary Poster garyposter@earthlink.net
Mon, 29 Apr 2002 19:20:37 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv1556/App/OFS/ServiceManager/Views/Browser/tests

Modified Files:
      Tag: Zope-3x-branch
	testAdder.py testBindings.py 
Log Message:
ComponentArchitecture reorganization; addition of for_container; addition of IWriteContainer.isAddable.

good news: all tests pass; bad news: after the new security system, my changes have some problems.  I had to punt on the default contents view of all folders for instance--hasServiceManager is causing a problem for some reason I couldn't divine, even with Shane's Checker tool.  I commented out the offending code on the contents.pt just to keep things up.

I tagged before committing: gary_CA-reorganization

changes more in depth (as I understand it, all or most approved :-) ):

(in ComponentArchitecture:)
 * changing implementation names to Global* (i.e., AdapterService becomes 
GlobalAdapterService) and giving each its own file (many are clumped together 
in hooks.py)
 * removing hooks.py in ComponentArchitecture, putting all functions in appropriate module above (i.e. getAdapter will be in the adapter module)
 * largely removing indirection (_hook) except for getService and 
getNextService
 * changing IServiceService.py to IServiceManager
 * changing Service.py to GlobalServiceManager.py (and class name too)
 * removing "provide*" functions (i.e., provideAdapter, provideUtility, etc.) 
and "defineService" from the __init__.py imports
 * change all global services to classes with appropriate methods as per 
interfaces
 * update all tests 
 * remove all of the "provide*" functions from the interfaces
 * renamed IComponentArchitecture to IPlacefulComponentArchitecture (hereafter IPCA), after long discussion with SteveA 
 * list Resources as one of core CA services in IPlacefulComponentArchitecture
 * build actual IPCA interface, not just import of service interfaces (because we want IPCA to be placeful, but the service interfaces do not need to be)
 * place functions implementing ICA actually in __init__
 * explicitly setting up services in zcml
 * created Global service interfaces, and placed the "provides" and "set" and "define" functions there: however, to keep the main interfaces clean and clear, I placed these global interfaces in the same file as the global implementations, hoping to clarify that these are not reusable interfaces but descriptive, one-time interfaces
 * built PlacefulSetup in Zope.ComponentArchitecture.tests for more specific CleanUp (a subclass).  PlacefulSetup is in the tests folder of the local ServiceManager.  AddableSetup also is available, in the AddableService tests.

(elsewhere in Zope3)
 * built for_container in addables
 * built isAddable for containers (after discussion with Jim, we decided an addable "contains" attribute in the zcml might not be the way to go.  I chose the isAddable approach for a number of reasons)
 * addableservice does some more checks in getting the addable list, pertinent to the above and to whether it can find the appropriate factories
 * a few more tests: a start of one in the local event service, and some more here and there

I'm sorry to add to the confusion of the big security changes, but I needed to either trash these changes or commit them: I'm a bit out of time for the moment.  If all else fails, again, I did tag the previous version.



=== Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests/testAdder.py 1.1.2.3 => 1.1.2.4 ===
 from Zope.App.OFS.Container.Views.Browser.tests.AdderBaseTests \
      import BaseRegistryTest, BaseAddingTest
+from Zope.App.OFS.Services.AddableService.tests.AddableSetup import \
+  AddableSetup
+from Zope.ComponentArchitecture import getServiceManager
 
-class Methods:
-    # Supply the methds needed by the bases.
-    
-    def setUp(self):
-        from Zope.App.OFS.ServiceManager.tests.PlacefulSetup import PlacefulSetup
-        self.__sandbox=PlacefulSetup()
-        from Zope.App.OFS.Services.AddableService.IAddableService import IAddableService
-        from Zope.App.OFS.Services.AddableService.GlobalAddableService \
-             import GlobalAddableService
-        self.__sandbox.serviceManager.defineService("AddableServices", IAddableService)
-        self.addableContent=GlobalAddableService()
-        self.__sandbox.serviceManager.provideService("AddableServices", self.addableContent)
-    
-    def tearDown(self):
-        self.__sandbox.tearDown()
+class Methods(AddableSetup):
+    # Supply the methods needed by the bases.
 
     def _TestView__newContext(self):
         from Zope.App.OFS.ServiceManager.ServiceManager import ServiceManager
@@ -47,10 +37,10 @@
 
     def _TestAdderView__registry(self):
         return 'AddableServices'
-    
+
 
 class RegistryTest(Methods, BaseRegistryTest, TestCase): pass
-class AddingTest(Methods, BaseAddingTest, TestCase): 
+class AddingTest(Methods, BaseAddingTest, TestCase):
     def setUp(self):
         Methods.setUp(self)
         BaseAddingTest.setUp(self)


=== Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests/testBindings.py 1.1.2.5 => 1.1.2.6 ===
 
 from Zope.App.OFS.ServiceManager.Views.Browser.Bindings \
-        import Bindings
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-
+    import Bindings
+from Zope.App.OFS.ServiceManager.tests.PlacefulSetup import \
+    PlacefulSetup
+from Zope.ComponentArchitecture import getService, getServiceManager
 
 class ITestService1(Interface): pass
 class ITestService2(Interface): pass
@@ -35,18 +36,16 @@
     __implements__ = ITestService2
 
 
-class ServiceManagerTests(CleanUp, TestCase):
+class ServiceManagerTests(PlacefulSetup, TestCase):
 
     def setUp(self):
-        from Zope.App.OFS.ServiceManager.tests.PlacefulSetup import PlacefulSetup
-        self.__sandbox=PlacefulSetup()
-        CleanUp.setUp(self)
-        from Zope.App.OFS.ServiceManager.ServiceManager import ServiceManager
-        self.__sandbox.rootFolder.setServiceManager(ServiceManager())
-        self.__sandbox.serviceManager.defineService('service1', ITestService1)
-        self.__sandbox.serviceManager.defineService('service2', ITestService2)
-        self.sm=self.__sandbox.rootFolder.getServiceManager()
-        
+        PlacefulSetup.setUp(self)
+        self.buildFolders()
+        self.createServiceManager()
+        self.sm=getServiceManager(self.rootFolder)
+        getServiceManager(None).defineService('service1', ITestService1)
+        getServiceManager(None).defineService('service2', ITestService2)
+
         sA = TestService1()
         sB = TestService1()
         sC = TestService2()
@@ -56,13 +55,10 @@
         self.sm.setObject('TestServiceC', sC)
 
         self.sm.bindService('service1', 'TestServiceA')
-        
-    def tearDown(self):
-        self.__sandbox.tearDown()
 
     def testGetServicesTable(self):
         view = Bindings(self.sm)
-        self.assertEqual(len(view.getServicesTable()), 2)
+        self.assertEqual(len(view.getServicesTable()), 8) #that is, 2+6
 
     def testServiceTableBound(self):
         view = Bindings(self.sm)
@@ -75,7 +71,7 @@
             
         self.assertEqual(serviceMap['bound'], 'TestServiceA')
 
-## Was commented:
+## XXX Was commented:
 ## """This test is not working (bug in getServicesTable(), returning
 ## 'Acquired' instead of 'None'"""
 ##