[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests - testConnectionConfiguration.py:1.1.2.1 testConnectionService.py:1.5.2.1

Marius Gedminas mgedmin@codeworks.lt
Tue, 10 Dec 2002 14:16:33 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests
In directory cvs.zope.org:/tmp/cvs-serv28246/lib/python/Zope/App/OFS/Services/ConnectionService/tests

Modified Files:
      Tag: named-component-configuration-branch
	testConnectionConfiguration.py testConnectionService.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/ConnectionService/tests/testConnectionConfiguration.py 1.1 => 1.1.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests/testConnectionConfiguration.py:1.1	Mon Dec  9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests/testConnectionConfiguration.py	Tue Dec 10 14:16:01 2002
@@ -68,7 +68,7 @@
         self.bindings = {}
 
     def queryConfigurationsFor(self, cfg, default=None):
-        return self.queryConfigurations(cfg.connectionName)
+        return self.queryConfigurations(cfg.name)
     queryConfigurationsFor = ContextMethod(queryConfigurationsFor)
 
     def queryConfigurations(self, name, default=None):
@@ -77,7 +77,7 @@
     queryConfigurations = ContextMethod(queryConfigurations)
 
     def createConfigurationsFor(self, cfg):
-        return self.createConfigurations(cfg.connectionName)
+        return self.createConfigurations(cfg.name)
     createConfigurationsFor = ContextMethod(createConfigurationsFor)
 
     def createConfigurations(self, name):
@@ -95,7 +95,6 @@
         PlacefulSetup.setUp(self)
         self.buildFolders()
         self.rootFolder.setServiceManager(ServiceManager())
-        sm = self.rootFolder.getServiceManager()
 
         self.default = traverse(self.rootFolder,
                            '++etc++Services/Packages/default')
@@ -118,6 +117,8 @@
         PlacefulSetup.tearDown(self)
 
     def test_getComponent(self):
+        # This should be already tested by ComponentConfiguration tests, but
+        # let's doublecheck
         self.assertEqual(self.config.getComponent(), self.da)
 
     def test_status(self):
@@ -126,10 +127,6 @@
         self.assertEqual(self.config.status, Active)
         cr = self.service.queryConfigurations('conn_name')
         self.assertEqual(cr.active(), self.config)
-
-    # Unit tests for ComponentConfiguration should take care
-    # of test_manage_afterAdd, test_manage_beforeDelete_and_unregistered,
-    # test_disallow_delete_when_active
 
 
 def test_suite():


=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests/testConnectionService.py 1.5 => 1.5.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests/testConnectionService.py:1.5	Mon Dec  9 10:26:42 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/tests/testConnectionService.py	Tue Dec 10 14:16:01 2002
@@ -1,14 +1,14 @@
 ##############################################################################
 #
 # Copyright (c) 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
-# 
+#
 ##############################################################################
 """DT_SQLVar Tests
 
@@ -16,8 +16,6 @@
 """
 
 import unittest
-from Zope.ComponentArchitecture.GlobalServiceManager import \
-     serviceManager as sm
 from Zope.App.Traversing import traverse
 from Zope.App.RDB.IZopeConnection import IZopeConnection
 from Zope.App.RDB.IZopeDatabaseAdapter import IZopeDatabaseAdapter
@@ -46,6 +44,10 @@
      import ConnectionConfiguration
 
 
+class ConnectionServiceForTests(ConnectionService):
+
+    __implements__ = ConnectionService.__implements__, IAttributeAnnotatable
+
 class DAStub:
 
     __implements__ = IZopeDatabaseAdapter, IAttributeAnnotatable
@@ -74,7 +76,7 @@
 
         self.default = traverse(self.rootFolder,
                            '++etc++Services/Packages/default')
-        self.default.setObject('conn_srv', ConnectionService())
+        self.default.setObject('conn_srv', ConnectionServiceForTests())
         self.service = traverse(self.default, 'conn_srv')
 
         self.cm = ZopeContainerAdapter(traverse(self.default, "configure"))
@@ -104,7 +106,7 @@
                          self.service.queryConnection('conn3'))
         self.assertEqual('Error',
                          self.service.queryConnection('conn3', 'Error'))
-        
+
     def testGetAvailableConnections(self):
         self.assertEqual(['conn1', 'conn2'],
                          sort(self.service.getAvailableConnections()))