[Zope3-checkins] CVS: Zope3/src/zope/app/content/tests -
test_sqlscript.py:1.17
Mohan Chandra
mchandra at zeomega.com
Fri Dec 19 11:53:47 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/content/tests
In directory cvs.zope.org:/tmp/cvs-serv28838/src/zope/app/content/tests
Modified Files:
test_sqlscript.py
Log Message:
Removal of Databaseconnection service
=== Zope3/src/zope/app/content/tests/test_sqlscript.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/content/tests/test_sqlscript.py:1.16 Thu Nov 27 08:59:17 2003
+++ Zope3/src/zope/app/content/tests/test_sqlscript.py Fri Dec 19 11:53:16 2003
@@ -18,7 +18,7 @@
from zope.app.tests import ztapi
from zope.interface import implements, classImplements
-from zope.app.interfaces.rdb import IConnectionService
+from zope.app.interfaces.rdb import IConnectionService, IZopeDatabaseAdapter
from zope.app.interfaces.rdb import IZopeConnection
from zope.app.interfaces.rdb import IZopeCursor
from zope.component import getService
@@ -66,6 +66,7 @@
return self.result
+
class ConnectionStub:
implements(IZopeConnection)
@@ -73,6 +74,15 @@
return CursorStub()
+class ConnectionUtilityStub:
+ implements(IZopeDatabaseAdapter)
+
+ def __init__(self):
+ self.connection = ConnectionStub()
+
+ def __call__(self):
+ return self.connection
+
class ConnectionServiceStub:
implements(IConnectionService, ISimpleService)
@@ -129,10 +139,10 @@
def setUp(self):
super(SQLScriptTest, self).setUp()
classImplements(SQLScript, IAttributeAnnotatable)
- sm.defineService('SQLDatabaseConnections', IConnectionService)
- sm.provideService('SQLDatabaseConnections', ConnectionServiceStub())
- self._old_getNextServiceManager = nextservice.getNextServiceManager
- nextservice.getNextServiceManager = getNextServiceManager
+ self.connectionUtilityStub = ConnectionUtilityStub()
+ ztapi.provideUtility(IZopeDatabaseAdapter, self.connectionUtilityStub,
+ 'my_connection')
+
self.caching_service = CachingServiceStub()
sm.defineService('Caching', ICachingService)
sm.provideService('Caching', self.caching_service)
@@ -147,7 +157,9 @@
AnnotationCacheable)
def tearDown(self):
- nextservice.getNextServiceManager = self._old_getNextServiceManager
+ pass
+
+ #nextservice.getNextServiceManager = self._old_getNextServiceManager
def _getScript(self):
return SQLScript("my_connection",
@@ -185,6 +197,12 @@
self.assertEqual('my_connection', script.connectionName)
script.connectionName = 'test_conn'
self.assertEqual('test_conn', script.connectionName)
+
+ def testgetConnection(self):
+ script = self._getScript()
+ name = script.connectionName
+ conns = script.getConnection()
+ self.assertEqual(conns, self.connectionUtilityStub.connection)
def testSQLScript(self):
result = self._getScript()(id=1)
More information about the Zope3-Checkins
mailing list