[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/tests - testConfigurations.py:1.3 testNameConfigurable.py:1.4
Steve Alexander
steve@cat-box.net
Wed, 18 Dec 2002 15:23:07 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/tests
In directory cvs.zope.org:/tmp/cvs-serv12654/lib/python/Zope/App/OFS/Services/tests
Modified Files:
testConfigurations.py testNameConfigurable.py
Log Message:
SteveA and Marius G.
We refactored the NamedComponentConfiguration and ComponentConfiguration.
Now, we have NamedConfiguration and NamedComponentConfiguration.
NamedConfigurable is now split into two parts, as appropriate to that
refactoring.
Cleaned up various extraneous imports, and changed various
self --> wrapped_self. (Interestingly, this act revealed one ContextMethod
that did not in fact need to be a ContextMethod.)
=== Zope3/lib/python/Zope/App/OFS/Services/tests/testConfigurations.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/tests/testConfigurations.py:1.2 Thu Dec 12 06:32:34 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/tests/testConfigurations.py Wed Dec 18 15:23:06 2002
@@ -21,12 +21,14 @@
from Interface import Interface
from Zope.App.OFS.Services.ConfigurationInterfaces \
- import Active, Registered, Unregistered
+ import Active, Registered, Unregistered
from Zope.App.DependencyFramework.Exceptions import DependencyError
from Zope.App.OFS.Services.Configuration import SimpleConfiguration
-from Zope.App.OFS.Services.Configuration import ComponentConfiguration
-from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup import PlacefulSetup
-from Zope.App.OFS.Services.tests.TestingServiceManager import TestingServiceManager
+from Zope.App.OFS.Services.Configuration import NamedComponentConfiguration
+from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \
+ import PlacefulSetup
+from Zope.App.OFS.Services.tests.TestingServiceManager \
+ import TestingServiceManager
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.DependencyFramework.IDependable import IDependable
from Zope.App.Traversing import traverse
@@ -70,26 +72,28 @@
self.assertRaises(DependencyError, cfg.manage_beforeDelete, cfg,
container)
- # deletion of a registered configuration causes it to become unregistered
+ # deletion of a registered configuration causes it to become
+ # unregistered
cfg.status = Registered
cfg.manage_beforeDelete(cfg, container)
self.assertEquals(cfg.status, Unregistered)
-class TestComponentConfiguration(TestSimpleConfiguration, PlacefulSetup):
+class TestNamedComponentConfiguration(TestSimpleConfiguration, PlacefulSetup):
def setUp(self):
PlacefulSetup.setUp(self)
self.buildFolders()
self.__sm = TestingServiceManager()
self.rootFolder.setServiceManager(self.__sm)
+ self.name = 'foo'
def test_getComponent(self):
# set up a component
path, component = 'foo', object()
self.rootFolder.setObject(path, component)
# set up a configuration
- cfg = ComponentConfiguration(path)
+ cfg = NamedComponentConfiguration(self.name, path)
cfg = ContextWrapper(cfg, self.rootFolder)
# check that getComponent finds the configuration
self.assertEquals(cfg.getComponent(), component)
@@ -99,7 +103,7 @@
path, component = 'foo', object()
self.rootFolder.setObject(path, component)
# set up a configuration
- cfg = ComponentConfiguration(path, 'Zope.TopSecret')
+ cfg = NamedComponentConfiguration(self.name, path, 'Zope.TopSecret')
cfg.getInterface = lambda: ITestComponent
cfg = ContextWrapper(cfg, self.rootFolder)
# check that getComponent finds the configuration
@@ -112,7 +116,7 @@
path, component = 'foo', ComponentStub()
self.rootFolder.setObject(path, component)
# set up a configuration
- cfg = ComponentConfiguration(path)
+ cfg = NamedComponentConfiguration(self.name, path)
self.rootFolder.setObject('cfg', cfg)
cfg = traverse(self.rootFolder, 'cfg')
# simulate IAddNotifiable
@@ -126,7 +130,7 @@
self.rootFolder.setObject(path, component)
component.addDependent('/cfg')
# set up a configuration
- cfg = ComponentConfiguration(path)
+ cfg = NamedComponentConfiguration(self.name, path)
cfg.status = Unregistered
self.rootFolder.setObject('cfg', cfg)
cfg = traverse(self.rootFolder, 'cfg')
@@ -136,13 +140,13 @@
self.assertEquals(component.dependents(), ())
-# NamedComponentConfiguration is too simple to need testing at the moment
+# NamedConfiguration is too simple to need testing at the moment
def test_suite():
return TestSuite((
makeSuite(TestSimpleConfiguration),
- makeSuite(TestComponentConfiguration),
+ makeSuite(TestNamedComponentConfiguration),
))
if __name__=='__main__':
=== Zope3/lib/python/Zope/App/OFS/Services/tests/testNameConfigurable.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Services/tests/testNameConfigurable.py:1.3 Thu Dec 12 10:28:18 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/tests/testNameConfigurable.py Wed Dec 18 15:23:06 2002
@@ -19,10 +19,9 @@
from unittest import TestCase, TestSuite, main, makeSuite
from Zope.App.OFS.Services.Configuration import NameConfigurable
+from Zope.App.OFS.Services.Configuration import NameComponentConfigurable
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.Proxy.ContextWrapper import getWrapperContainer
-from Zope.Proxy.ContextWrapper import getWrapperContext
-
class ConfigurationStub:
@@ -117,6 +116,13 @@
subject._bindings['Bar'] = 0 # false values should be filtered out
self.assertEquals(tuple(subject.listConfigurationNames()), ('Foo',))
+class TestNameComponentConfigurable(TestNameConfigurable):
+
+ def setUp(self):
+ self.container = object()
+ self.subject = ContextWrapper(NameComponentConfigurable(),
+ self.container)
+
def test_queryActiveComponent(self):
subject = self.subject
self.assertEquals(subject.queryActiveComponent('xyzzy'), None)
@@ -133,6 +139,7 @@
def test_suite():
return TestSuite((
makeSuite(TestNameConfigurable),
+ makeSuite(TestNameComponentConfigurable),
))