[Zope-Checkins] CVS: Products/DCOracle2/test -
test_zopeda.py:1.1.2.1 test_zoracleda.py:1.1.2.1
test_zoracleda_basics.py:1.1.2.1
Chris Withers
cvs-admin at zope.org
Tue Nov 4 16:47:46 EST 2003
Update of /cvs-repository/Products/DCOracle2/test
In directory cvs.zope.org:/tmp/cvs-serv22843/test
Modified Files:
Tag: chrisw_fixconnectionleak_branch
test_zopeda.py test_zoracleda.py test_zoracleda_basics.py
Log Message:
First pass at Thread Pool connection model.
Also better handling for errors in DB.query method.
=== Products/DCOracle2/test/test_zopeda.py 1.1 => 1.1.2.1 ===
--- Products/DCOracle2/test/test_zopeda.py:1.1 Fri Oct 31 12:49:40 2003
+++ Products/DCOracle2/test/test_zopeda.py Tue Nov 4 16:47:45 2003
@@ -67,16 +67,15 @@
### UI forms
def test_manage_main(self):
- self.da.manage_main(None,self.REQUEST)
-
+ self.da.manage_main(self.da,self.REQUEST)
+
def test_manage_properties(self):
- self.da.manage_properties(None,self.REQUEST)
+ self.da.manage_properties(self.da,self.REQUEST)
def test_manage_testForm(self):
- self.da.manage_testForm(None,self.REQUEST)
+ self.da.manage_testForm(self.da,self.REQUEST)
### support methods
-
def test_title_and_id(self):
self.failUnless(
isinstance(self.da.title_and_id(),StringType)
@@ -84,7 +83,7 @@
def test_title_or_id(self):
self.failUnless(
- isinstance(self.da.title_and_id(),StringType)
+ isinstance(self.da.title_or_id(),StringType)
)
def test_connected(self):
@@ -118,7 +117,7 @@
def test_open_connection(self):
self.failIf(self.da.connected())
- self.da.manage_open_connection()
+ self.da.manage_open_connection(self.REQUEST)
self.failUnless(self.da.connected())
def test_connect(self):
=== Products/DCOracle2/test/test_zoracleda.py 1.1 => 1.1.2.1 ===
--- Products/DCOracle2/test/test_zoracleda.py:1.1 Fri Oct 31 12:49:40 2003
+++ Products/DCOracle2/test/test_zoracleda.py Tue Nov 4 16:47:45 2003
@@ -4,10 +4,14 @@
import test_dcoracle2
import test_zoracleda_basics
+ import test_connections
+ import test_DB
return unittest.TestSuite((
test_dcoracle2.test_suite(),
unittest.makeSuite(test_zoracleda_basics.test_ZOracleDA),
+ unittest.makeSuite(test_connections.test_connections),
+ unittest.makeSuite(test_DB.test_DB),
))
if __name__ == '__main__':
=== Products/DCOracle2/test/test_zoracleda_basics.py 1.1 => 1.1.2.1 ===
--- Products/DCOracle2/test/test_zoracleda_basics.py:1.1 Fri Oct 31 12:49:40 2003
+++ Products/DCOracle2/test/test_zoracleda_basics.py Tue Nov 4 16:47:45 2003
@@ -23,6 +23,84 @@
"create table users (name varchar(10), password varchar(10), role varchar(10))",
)
+ ### UI forms
+ def test_manage_browse(self):
+ # try without connection
+ self.da.manage_browse(self.da,self.REQUEST)
+ # now with connection
+ self.da()
+ self.da.manage_browse(self.da,self.REQUEST)
+
+ def test_manage_trace(self):
+ self.da.manage_trace(self.da,self.REQUEST)
+
+
+ ### debug methods
+
+ def test_ZDCO2VERSION(self):
+ self.da()
+ self.da.ZDCO2VERSION()
+
+ def test_ZDCO2DEBUG(self):
+ self.da()
+ try:
+ self.da.ZDCO2DEBUG()
+ except NotImplementedError:
+ # this is okay, just not compiled in DEBUG mode
+ pass
+
+ ### store procedures
+ def test_stored_procedure(self):
+ from Products.ZOracleDA.DA import manage_addZOracleStoredProcedure
+ manage_addZOracleStoredProcedure(self.folder,
+ 'test_sp',
+ '',
+ 'test_connection',
+ 'emp_actions.findempbyname',
+ 'never')
+
+ # due to yucky security check, we need to reach inside
+ sp = self.folder.test_sp
+ sp._connect()
+ sp._register()
+ results = sp._v_proc(NAME='JONES')
+ sp._lobConvert(results)
+ self.assertEqual(results,7566)
+
+ ### close connections
+ def test_manage_close_connection2(self,open=1):
+ from Products.ZOracleDA import connections
+ from test_connections import _clearPool
+ _clearPool(connections)
+ if open:
+ self.da().getDB()
+ self.assertEqual(connections.countConnections(self._getConnectionString()),
+ 1)
+ self.da.manage_close_connection(self.REQUEST)
+ self.assertEqual(connections.countConnections(self._getConnectionString()),
+ 0)
+
+ def test_manage_close_connection_closed2(self):
+ self.test_manage_close_connection2(0)
+
+ ### edit connections
+ def test_manage_edit_closes(self):
+ from Products.ZOracleDA import connections
+ from test_connections import _clearPool
+ _clearPool(connections)
+ self.da().getDB()
+ self.assertEqual(connections.countConnections(self._getConnectionString()),
+ 1)
+ self.test_manage_edit()
+ self.assertEqual(connections.countConnections(self._getConnectionString()),
+ 0)
+
+ ### bad connection string
+ def test_bad_connectionstring(self):
+ from Products.ZOracleDA.DCOracle2 import DatabaseError
+ self.da.manage_edit('','bad/bad at badbadbaddb',1,self.REQUEST)
+ self.assertRaises(DatabaseError,self.da().getDB)
+
if __name__ == '__main__':
unittest.main()
More information about the Zope-Checkins
mailing list