[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/tests - testProvideClass.py:1.1.2.7 testServiceProvideClass.py:1.1.2.8 testAddable.py:NONE
Gary Poster
garyposter@earthlink.net
Mon, 22 Apr 2002 15:03:54 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/tests
In directory cvs.zope.org:/tmp/cvs-serv31509/App/ZMI/tests
Modified Files:
Tag: Zope-3x-branch
testProvideClass.py testServiceProvideClass.py
Removed Files:
Tag: Zope-3x-branch
testAddable.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/ZMI/tests/testProvideClass.py 1.1.2.6 => 1.1.2.7 ===
class ProvideClassTest(CleanUp, unittest.TestCase):
+ def getService_hook(self, context, name):
+ if name != "AddableContent" or context is not None: raise NotFoundError
+ return self.addableService
+
+ def provideFactory_hook(self, qname, factory):
+ self._factories[qname] = factory
+
+ def createObject_hook(self, place, name, args=[], kwargs={}):
+ return self._factories[name](*args, **kwargs)
+
+ def setUp(self):
+ from Zope.ComponentArchitecture import hooks
+ self.__old_getService_hook=hooks.getService_hook
+ self.__old_provideFactory_hook=hooks.provideFactory_hook
+ self.__old_createObject_hook=hooks.createObject_hook
+ self._factories={}
+ hooks.getService_hook=self.getService_hook
+ hooks.provideFactory_hook=self.provideFactory_hook
+ hooks.createObject_hook=self.createObject_hook
+ from Zope.App.OFS.Services.AddableService.GlobalAddableService \
+ import GlobalAddableService
+ self.addableService=GlobalAddableService()
+
+ def tearDown(self):
+ from Zope.ComponentArchitecture import hooks
+ hooks.getService_hook=self.__old_getService_hook
+ hooks.provideFactory_hook=self.__old_provideFactory_hook
+ hooks.createObject_hook=self.__old_createObject_hook
+
def testProvideClass(self):
- from Zope.ComponentArchitecture.hooks import createObject
+ from Zope.ComponentArchitecture import createObject, getService
from Zope.App.ZMI import provideClass
- from Zope.App.ZMI.Addable import ContentAddables
- provideClass(ContentAddables, 'My.Test.Addable', MyAddableObject,
+ provideClass("AddableContent", 'My.Test.Addable', MyAddableObject,
None, 'Testing')
object = createObject(None,'My.Test.Addable')
=== Zope3/lib/python/Zope/App/ZMI/tests/testServiceProvideClass.py 1.1.2.7 => 1.1.2.8 ===
import unittest, sys, Interface
-from Zope.App.ZMI.Addable import ServiceAddables
from Zope.App.ZMI import provideClass
@@ -26,6 +25,7 @@
from Zope.Configuration.xmlconfig import xmlconfig
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
+from Zope.ComponentArchitecture import getService
@@ -34,6 +34,35 @@
class ServiceProvideClassTest(CleanUp, unittest.TestCase):
+ def getService_hook(self, context, name):
+ if name != "AddableServices" or context is not None: raise NotFoundError
+ return self.addableService
+
+ def provideFactory_hook(self, qname, factory):
+ self._factories[qname] = factory
+
+ def createObject_hook(self, place, name, args=[], kwargs={}):
+ return self._factories[name](*args, **kwargs)
+
+ def setUp(self):
+ from Zope.ComponentArchitecture import hooks
+ self.__old_getService_hook=hooks.getService_hook
+ self.__old_provideFactory_hook=hooks.provideFactory_hook
+ self.__old_createObject_hook=hooks.createObject_hook
+ self._factories={}
+ hooks.getService_hook=self.getService_hook
+ hooks.provideFactory_hook=self.provideFactory_hook
+ hooks.createObject_hook=self.createObject_hook
+ from Zope.App.OFS.Services.AddableService.GlobalAddableService \
+ import GlobalAddableService
+ self.addableService=GlobalAddableService()
+
+ def tearDown(self):
+ from Zope.ComponentArchitecture import hooks
+ hooks.getService_hook=self.__old_getService_hook
+ hooks.provideFactory_hook=self.__old_provideFactory_hook
+ hooks.createObject_hook=self.__old_createObject_hook
+
def testServiceProvideClassDirective(self):
serviceName = (
'Zope.App.ZMI.tests.testServiceProvideClass.MyAddableService')
@@ -58,8 +87,8 @@
</zopeConfigure>
''' %(serviceName, serviceName)))
- addables = ServiceAddables.getAddables(None)
- self.assertEqual(addables[0].id(), serviceName)
+ addables = getService(None,"AddableServices").getAddables(None)
+ self.assertEqual(addables[0].id, serviceName)
=== Removed File Zope3/lib/python/Zope/App/ZMI/tests/testAddable.py ===