[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests - testAdder.py:1.1.2.3 testBindings.py:1.1.2.5
Gary Poster
garyposter@earthlink.net
Mon, 22 Apr 2002 15:03:52 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv31509/App/OFS/ServiceManager/Views/Browser/tests
Modified Files:
Tag: Zope-3x-branch
testAdder.py testBindings.py
Log Message:
1. As per ZopeTop discussion, moved Addable out of ZMI into the Services folder, and turned it into a true service (this involved a lot of small changes, particularly in the folders and a number of tests) and gave it some hooks
2. used SteveA's ContextWrapper.ContextMethod to make the ServiceManager and Services placefully look up to parent placeful equivalents
3. Made Event into a more standard service, and gave it some hooks
4. Built the beginning of a placeful EventService (will need tests, and views, and EventChannels, and more meat; just wanted to check this in for now)
5. made it so you can't add an item to a folder with a blank string id, and updated the folder interface
6. some typos fixed here and there
7. a few more tests here and there
I'm checking this in then checking it out again to check my work; also tagged previous version as gary-service_update.
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests/testAdder.py 1.1.2.2 => 1.1.2.3 ===
from Zope.App.OFS.Container.Views.Browser.tests.AdderBaseTests \
import BaseRegistryTest, BaseAddingTest
-from Zope.App.ZMI.Addable import ServiceAddables
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()
def _TestView__newContext(self):
from Zope.App.OFS.ServiceManager.ServiceManager import ServiceManager
@@ -34,11 +46,14 @@
return Adder(container)
def _TestAdderView__registry(self):
- return ServiceAddables
+ return 'AddableServices'
class RegistryTest(Methods, BaseRegistryTest, TestCase): pass
-class AddingTest(Methods, BaseAddingTest, TestCase): pass
+class AddingTest(Methods, BaseAddingTest, TestCase):
+ def setUp(self):
+ Methods.setUp(self)
+ BaseAddingTest.setUp(self)
def test_suite():
return TestSuite([makeSuite(RegistryTest),
=== Zope3/lib/python/Zope/App/OFS/ServiceManager/Views/Browser/tests/testBindings.py 1.1.2.4 => 1.1.2.5 ===
from Interface import Interface
-from Zope.App.OFS.ServiceManager.ServiceManager import ServiceManager
from Zope.App.OFS.ServiceManager.Views.Browser.Bindings \
import Bindings
-from Zope.ComponentArchitecture import provideService, defineService
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-#set up hooks
-from Zope.App.OFS.ServiceManager.hooks import getServiceManager_hook, \
- getNextServiceManager_hook
-from Zope.ComponentArchitecture import hooks
-hooks.getServiceManager_hook=getServiceManager_hook
-hooks.getNextServiceManager_hook=getNextServiceManager_hook
-
class ITestService1(Interface): pass
class ITestService2(Interface): pass
@@ -47,22 +38,27 @@
class ServiceManagerTests(CleanUp, TestCase):
def setUp(self):
+ from Zope.App.OFS.ServiceManager.tests.PlacefulSetup import PlacefulSetup
+ self.__sandbox=PlacefulSetup()
CleanUp.setUp(self)
- sm = ServiceManager()
- defineService('service1', ITestService1)
- defineService('service2', ITestService2)
+ 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()
sA = TestService1()
sB = TestService1()
sC = TestService2()
- sm.setObject('TestServiceA', sA)
- sm.setObject('TestServiceB', sB)
- sm.setObject('TestServiceC', sC)
+ self.sm.setObject('TestServiceA', sA)
+ self.sm.setObject('TestServiceB', sB)
+ self.sm.setObject('TestServiceC', sC)
- sm.bindService('service1', 'TestServiceA')
+ self.sm.bindService('service1', 'TestServiceA')
- self.sm = sm
+ def tearDown(self):
+ self.__sandbox.tearDown()
def testGetServicesTable(self):
view = Bindings(self.sm)
@@ -82,10 +78,15 @@
## Was commented:
## """This test is not working (bug in getServicesTable(), returning
## 'Acquired' instead of 'None'"""
-##
+##
+## Then further commented:
## However, we're now acquiring from the globally defined services,
## so it is appropriate to return 'Acquired'.
-
+##
+## To which I now add:
+## I actually think that it should be 'None' after all. Where is
+## service2 provided globally?
+##
def testServiceTableNone(self):
view = Bindings(self.sm)
services = view.getServicesTable()
@@ -94,8 +95,7 @@
if sMap['name'] == 'service2':
serviceMap = sMap
break
-
- self.assertEqual(serviceMap['bound'], 'Acquired')
+ self.assertEqual(serviceMap['bound'], 'None')
def test_suite():
return TestSuite([makeSuite(ServiceManagerTests)])