[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/tests - testConfigurationStatusProperty.py:1.2.10.1
Marius Gedminas
mgedmin@codeworks.lt
Wed, 11 Dec 2002 11:07:38 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/tests
In directory cvs.zope.org:/tmp/cvs-serv29432/lib/python/Zope/App/OFS/Services/tests
Modified Files:
Tag: named-component-configuration-branch
testConfigurationStatusProperty.py
Log Message:
Bugfix for the following scenario:
1. create and configure an SQLConnectionService
2. create and configure a database adapter&connection
3. disable the SQLConnectionService
4. database connection configuration views stop working, and it is impossible
to view ++etc++Services/Packages/default/configure/
=== Zope3/lib/python/Zope/App/OFS/Services/tests/testConfigurationStatusProperty.py 1.2 => 1.2.10.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/tests/testConfigurationStatusProperty.py:1.2 Sat Nov 30 13:35:55 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/tests/testConfigurationStatusProperty.py Wed Dec 11 11:07:38 2002
@@ -29,11 +29,16 @@
from Zope.App.OFS.Services.ConfigurationInterfaces \
import Active, Unregistered, Registered
from Zope.Proxy.ContextWrapper import ContextWrapper
+from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
+
class TestingConfiguration(TestingConfiguration):
status = ConfigurationStatusProperty("Services")
service_type = "Test"
+class PassiveConfiguration(TestingConfiguration):
+ status = ConfigurationStatusProperty("NoSuchService")
+
class TestingConfigurationRegistry(TestingConfigurationRegistry):
class_ = TestingConfiguration
@@ -46,7 +51,13 @@
def getService(self, name):
if name == "Services":
return self
- raise ValueError("Wrong service name", name)
+ raise ComponentLookupError("Wrong service name", name)
+
+ def queryService(self, name, default=None):
+ if name == "Services":
+ return self
+ else:
+ return default
def queryConfigurationsFor(self, configuration, default=None):
if configuration.service_type != "Test":
@@ -68,7 +79,7 @@
self.__sm = TestingServiceManager()
self.rootFolder.setServiceManager(self.__sm)
- def test(self):
+ def test_property(self):
configa = ContextWrapper(TestingConfiguration('a'), self.rootFolder)
self.assertEqual(configa.status, Unregistered)
@@ -106,6 +117,32 @@
self.assertEqual(configc.status, Unregistered)
self.assertEqual(configb.status, Registered)
self.assertEqual(configa.status, Registered)
+
+ def test_passive(self):
+ # scenario:
+ # 1. create and configure an SQLConnectionService
+ # 2. create and configure a database adapter&connection
+ # 3. disable SQLConnectionService
+ # now the ConnectionConfiguration.status cannot access the
+ # SQLConnectionService
+
+ configa = ContextWrapper(PassiveConfiguration('a'), self.rootFolder)
+ self.assertEqual(configa.status, Unregistered)
+
+ try:
+ configa.status = Registered
+ except ComponentLookupError:
+ self.assertEqual(configa.status, Unregistered)
+ else:
+ self.fail("should complain about missing service")
+
+ try:
+ configa.status = Active
+ except ComponentLookupError:
+ self.assertEqual(configa.status, Unregistered)
+ else:
+ self.fail("should complain about missing service")
+
def test_suite():
return TestSuite((