[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests - testServiceConfiguration.py:1.3.2.1 testServiceManager.py:1.4.10.1
Marius Gedminas
mgedmin@codeworks.lt
Tue, 10 Dec 2002 14:16:04 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests
In directory cvs.zope.org:/tmp/cvs-serv28246/lib/python/Zope/App/OFS/Services/ServiceManager/tests
Modified Files:
Tag: named-component-configuration-branch
testServiceConfiguration.py testServiceManager.py
Log Message:
Refactoring of configuration views:
- new interfaces INamedComponentConfiguration, INameConfigurable,
implemented in NamedComponentConfiguration, NameConfigurable, simplify
the case where configurations are identified by a name (service types,
connections, caches, queries, etc)
- common views for INamedComponentConfiguration, INameConfigurable
- refactored ServiceManager and ConnectionService to take advantage of the
new infrastructure
- incidentally wrote several unit tests for configuration classes
- removed caching from ComponentConnection.getComponent; this exposed a bug
in LocalEventService tests
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceConfiguration.py 1.3 => 1.3.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceConfiguration.py:1.3 Thu Dec 5 12:00:44 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceConfiguration.py Tue Dec 10 14:16:03 2002
@@ -70,7 +70,7 @@
self._dependents = tuple(
[d for d in self._dependents if d != location]
)
-
+
def dependents(self):
return self._dependents
@@ -93,14 +93,11 @@
self.__c = traverse(default, 'c')
self.__cm = ZopeContainerAdapter(traverse(default, "configure"))
-
+
self.__cm.setObject('', configuration)
self.__config = traverse(default, 'configure/1')
- def test_getComponent(self):
- self.assertEqual(self.__config.getComponent(), self.__c)
-
def test_activated(self):
old = self.__c._bound
self.__config.activated()
@@ -111,6 +108,15 @@
self.__config.deactivated()
self.assertEqual(self.__c._unbound, old+('test_service',))
+ def test_getInterface(self):
+ self.assertEquals(self.__config.getInterface(), ITestService)
+
+ # XXX the following tests check the same things as
+ # Zope.App.OFS.Services.tests.testConfigurations, but in a different way
+
+ def test_getComponent(self):
+ self.assertEqual(self.__config.getComponent(), self.__c)
+
def test_manage_afterAdd(self):
self.assertEqual(self.__c._dependents,
('/++etc++Services/Packages/default/configure/1', ))
@@ -135,7 +141,7 @@
pass # OK
else:
self.failUnless(0, "Should have gotten a depency error")
-
+
def test_suite():
return makeSuite(Test)
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceManager.py 1.4 => 1.4.10.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceManager.py:1.4 Sat Nov 30 13:39:18 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceManager.py Tue Dec 10 14:16:03 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -59,7 +59,7 @@
self.createServiceManager()
sm = traverse(self.rootFolder, '++etc++Services')
default = traverse(sm, 'Packages/default')
-
+
ts = TestService()
default.setObject('test_service1', ts)
configuration = ServiceConfiguration(
@@ -109,9 +109,9 @@
sm = traverse(self.rootFolder, '++etc++Services')
traverse(sm, 'Packages/default/configure/1').status = Unregistered
-
+
self.assertEqual(getService(self.rootFolder, 'test_service'), root_ts)
-
+
def testContextServiceLookup(self):
self.testGetService() # set up localservice
sm=getServiceManager(self.rootFolder)
@@ -124,14 +124,14 @@
self.folder1.setServiceManager(ServiceManager())
sm2=getServiceManager(self.folder1)
-
+
self.assertEqual(getService(self.folder1, 'test_service'),
sm.Packages['default']['test_service1'])
def testComponentArchitectureServiceLookup(self):
self.rootFolder.setServiceManager(ServiceManager())
self.folder1.setServiceManager(ServiceManager())
-
+
ts = TestService()
globsm=getServiceManager(None)
@@ -145,7 +145,7 @@
from Zope.App.OFS.Services.ServiceManager.Module import Manager
import Zope.App.OFS.Services.ServiceManager.tests.Sample1
import Zope.App.OFS.Services.ServiceManager.tests.Sample2
-
+
self.rootFolder.setServiceManager(ServiceManager())
sm=getServiceManager(self.rootFolder)
Packages = cw(sm.Packages, sm, name='Packages')
@@ -180,16 +180,16 @@
self.assertEqual(
sm.resolve("Zope.App.OFS.Services.ServiceManager.tests.Sample2.y"),
"sample 2")
-
+
self.assertEqual(sm.resolve("XXX.ZZZ.ZZZ"), 42)
self.assertEqual(sm.resolve("XXX.ZZZ."), 42)
self.assertEqual(sm.resolve("XXX.ZZZ.x"), "root m2")
-
+
self.assertEqual(sm2.resolve("XXX.ZZZ.ZZZ"), 42)
self.assertEqual(sm2.resolve("XXX.ZZZ."), 42)
self.assertEqual(sm2.resolve("XXX.ZZZ.x"), "root m2")
-
-
+
+
def test_suite():
loader=TestLoader()
return loader.loadTestsFromTestCase(ServiceManagerTests)