[Zope-Checkins] CVS: Products/DCOracle2/test - test9.py:1.11 test8.py:1.6 test7.py:1.2 test6.py:1.4 test5.py:1.6 test4.py:1.7 test3.py:1.7 test2.py:1.5 test11.py:1.3 test10.py:1.4 test1.py:1.3 stest.py:1.2

Chris Withers cvs-admin at zope.org
Thu Oct 30 12:06:36 EST 2003


Update of /cvs-repository/Products/DCOracle2/test
In directory cvs.zope.org:/tmp/cvs-serv9117

Modified Files:
	test9.py test8.py test7.py test6.py test5.py test4.py test3.py 
	test2.py test11.py test10.py test1.py stest.py 
Log Message:
converted test scripts to unit tests.


=== Products/DCOracle2/test/test9.py 1.10 => 1.11 ===
--- Products/DCOracle2/test/test9.py:1.10	Mon Feb 25 11:21:06 2002
+++ Products/DCOracle2/test/test9.py	Thu Oct 30 12:06:34 2003
@@ -1,44 +1,480 @@
-#
-import DCOracle2
 import common
-from pprint import pprint
-import sys
-
-db = DCOracle2.connect(common.getConnectionString())
-
-
-d = db.describe('emp_actions')
-
-print db.decodedesc(d); sys.exit(0)
-
-
-#pprint(db.collapsedesc(d))
-
-e = db.describe('emp')
-
-#pprint(db.collapsedesc(e))
-
-p = db.mapproc('emp_actions')
-
-#print p
-
-find = db.procedure.scott.emp_actions.find
-findy = db.procedure.scott.emp_actions.findy
-
-#print find
-#print dir(find)
-
-#find.setsize(0,12)
-print find(7902)
+import DCOracle2
+import unittest
 
-print db.procedure.scott.emp_actions.findp(7902)
+class test_stored_procedures(common.TestCase):
 
-try:
-    print findy(7902,"Manager")
-except DCOracle2.DatabaseError:
-    (type, value, tb) = sys.exc_info()
-    print value[1]
-    otb = DCOracle2.traceback(format=1)
-    #print otb
+    def test_describe(self):
+        
+        d = self.db.describe('emp_actions')
+
+        self.assertEqual(
+            self.db.decodedesc(d),
+            self.username+'.EMP_ACTIONS package '+\
+            '\n\tEMPCUR procedure '
+            '\n\t\tCSR argument  OUT REF CURSOR'
+            '\n\tFIND function returns VARCHAR2 '
+            '\n\t\tEMPID argument  IN NUMBER'
+            '\n\tFINDEMPBYNAME procedure '
+            '\n\t\tNAME argument  IN VARCHAR2'
+            '\n\t\tID argument  OUT NUMBER'
+            '\n\tFINDEMPBYNAMEI function returns NUMBER '
+            '\n\t\tNAME argument  IN VARCHAR2'
+            '\n\tFINDMGR procedure '
+            '\n\t\tMGRID argument  IN NUMBER'
+            '\n\t\tCUR argument  IN OUT REF CURSOR'
+            '\n\tFINDP procedure '
+            '\n\t\tEMPID argument  IN NUMBER'
+            '\n\t\tEMPNAME argument  OUT VARCHAR2'
+            '\n\tFINDR procedure '
+            '\n\t\tEMPID argument  IN NUMBER'
+            '\n\t\tMGRID argument  IN OUT NUMBER'
+            '\n\tFINDY procedure '
+            '\n\t\tEMPID argument  IN NUMBER'
+            '\n\t\tEMPNAME argument  OUT VARCHAR2'
+            '\n\t\tEJOB argument  IN OUT VARCHAR2'
+            '\n\tNUM procedure '
+            '\n\t\tVALUE argument  IN OUT NUMBER'
+            '\n\tRETURNTAB procedure '
+            '\n\t\tPOEM argument  OUT TABLE OF VARCHAR2'
+            '\n\tTAKETAB procedure '
+            '\n\t\tIDS argument  IN TABLE OF VARCHAR2'
+            '\n\tTESTI procedure '
+            '\n\t\tNAME argument  IN VARCHAR2'
+            '\n\t\tID argument  IN NUMBER'
+            )
+
+        self.assertEqual(
+            self.db.collapsedesc(d),
+            [self.username,
+              'EMP_ACTIONS',
+              'package',
+              [['',
+                   'EMPCUR',
+                   'procedure',
+                   [['', 'CSR', 'argument', (102, 0, 0, 0, 0, ('OUT',))]]],
+                 ['',
+                     'FIND',
+                     'function',
+                     [['', None, 'argument', (1, 0, 0, 0, 0, ('OUT',))],
+                          ['', 'EMPID', 'argument', (2, 22, 38, 0, 0, ('IN',))]]],
+                 ['',
+                     'FINDEMPBYNAME',
+                     'procedure',
+                     [['', 'NAME', 'argument', (1, 0, 0, 0, 0, ('IN',))],
+                          ['', 'ID', 'argument', (2, 22, 0, 0, 0, ('OUT',))]]],
+                 ['',
+                     'FINDEMPBYNAMEI',
+                     'function',
+                     [['', None, 'argument', (2, 22, 38, 0, 0, ('OUT',))],
+                          ['', 'NAME', 'argument', (1, 0, 0, 0, 0, ('IN',))]]],
+                 ['',
+                     'FINDMGR',
+                     'procedure',
+                     [['', 'MGRID', 'argument', (2, 22, 38, 0, 0, ('IN',))],
+                          ['', 'CUR', 'argument', (102, 22, 38, 0, 0, ('IN', 'OUT'))]]],
+                 ['',
+                     'FINDP',
+                     'procedure',
+                     [['', 'EMPID', 'argument', (2, 22, 38, 0, 0, ('IN',))],
+                          ['', 'EMPNAME', 'argument', (1, 0, 0, 0, 0, ('OUT',))]]],
+                 ['',
+                     'FINDR',
+                     'procedure',
+                     [['', 'EMPID', 'argument', (2, 22, 38, 0, 0, ('IN',))],
+                          ['', 'MGRID', 'argument', (2, 22, 38, 0, 0, ('IN', 'OUT'))]]],
+                 ['',
+                     'FINDY',
+                     'procedure',
+                     [['', 'EMPID', 'argument', (2, 22, 38, 0, 0, ('IN',))],
+                          ['', 'EMPNAME', 'argument', (1, 0, 0, 0, 0, ('OUT',))],
+                          ['', 'EJOB', 'argument', (1, 0, 0, 0, 0, ('IN', 'OUT'))]]],
+                 ['',
+                     'NUM',
+                     'procedure',
+                     [['', 'VALUE', 'argument', (2, 22, 0, 0, 0, ('IN', 'OUT'))]]],
+                 ['',
+                     'RETURNTAB',
+                     'procedure',
+                     [['',
+                            'POEM',
+                            'argument',
+                            (251,
+                                   0,
+                                   0,
+                                   0,
+                                   0,
+                                   ('OUT',),
+                                   ['', None, 'argument', (1, 20, 0, 0, 0, ('OUT',))])]]],
+                 ['',
+                     'TAKETAB',
+                     'procedure',
+                     [['',
+                            'IDS',
+                            'argument',
+                            (251,
+                                   0,
+                                   0,
+                                   0,
+                                   0,
+                                   ('IN',),
+                                   ['', None, 'argument', (1, 20, 0, 0, 0, ('IN',))])]]],
+                 ['',
+                     'TESTI',
+                     'procedure',
+                     [['', 'NAME', 'argument', (1, 0, 0, 0, 0, ('IN',))],
+                          ['', 'ID', 'argument', (2, 22, 38, 0, 0, ('IN',))]]]]]
+            )
+
+    def test_describe2(self):
+
+        self.assertEqual(
+            self.db.collapsedesc(self.db.describe('emp')),
+            [self.username,
+              'EMP',
+              'table',
+              [['', 'EMPNO', 'column', (2, 22, 4, 0, 0, ())],
+                 ['', 'ENAME', 'column', (1, 10, 0, 0, 1, ())],
+                 ['', 'JOB', 'column', (1, 9, 0, 0, 1, ())],
+                 ['', 'MGR', 'column', (2, 22, 4, 0, 1, ())],
+                 ['', 'HIREDATE', 'column', (12, 7, 0, 0, 1, ())],
+                 ['', 'SAL', 'column', (2, 22, 7, 2, 1, ())],
+                 ['', 'COMM', 'column', (2, 22, 7, 2, 1, ())],
+                 ['', 'DEPTNO', 'column', (2, 22, 2, 0, 1, ())]]]
+            )
+
+    def test_mapproc(self):
+
+        self.assertEqual(
+            self.db.mapproc('emp_actions'),
+            {'EMP_ACTIONS.RETURNTAB': [
+              '',
+              'RETURNTAB',
+              'procedure', [
+                ['',
+                 'POEM',
+                 'argument',
+                 (251, 0, 0, 0, 0, ('OUT',),
+                  ['', None, 'argument', (1, 20, 0, 0, 0, ('OUT',))])]
+                ]
+              ],
+             'EMP_ACTIONS.FINDR': [
+              '',
+              'FINDR',
+              'procedure', [
+                ['',
+                 'EMPID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))],
+                ['',
+                 'MGRID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN', 'OUT'))]
+                ]
+              ],
+             'EMP_ACTIONS.FINDY': [
+              '',
+              'FINDY',
+              'procedure', [
+                ['',
+                 'EMPID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))],
+                ['',
+                 'EMPNAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('OUT',))],
+                ['',
+                 'EJOB',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('IN', 'OUT'))]
+                ]
+              ],
+             'EMP_ACTIONS.FINDEMPBYNAMEI': [
+              '',
+              'FINDEMPBYNAMEI',
+              'function', [
+                ['',
+                 None,
+                 'argument',
+                 (2, 22, 38, 0, 0, ('OUT',))],
+                ['',
+                 'NAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('IN',))]
+                ]
+              ],
+             'EMP_ACTIONS': [
+            self.username,
+            'EMP_ACTIONS',
+            'package', [
+              ['',
+               'EMPCUR',
+               'procedure', [
+                ['',
+                 'CSR',
+                 'argument',
+                 (102, 0, 0, 0, 0, ('OUT',))]
+                ]
+               ],
+              ['',
+               'FIND',
+               'function', [
+                ['',
+                 None,
+                 'argument',
+                 (1, 0, 0, 0, 0, ('OUT',))],
+                ['',
+                 'EMPID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))]
+                ]
+               ],
+              ['',
+               'FINDEMPBYNAME',
+               'procedure', [
+                ['',
+                 'NAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('IN',))],
+                ['',
+                 'ID',
+                 'argument',
+                 (2, 22, 0, 0, 0, ('OUT',))]
+                ]
+               ],
+              ['',
+               'FINDEMPBYNAMEI',
+               'function', [
+                ['',
+                 None,
+                 'argument',
+                 (2, 22, 38, 0, 0, ('OUT',))],
+                ['',
+                 'NAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('IN',))]
+                ]
+               ],
+              ['',
+               'FINDMGR',
+               'procedure', [
+                ['',
+                 'MGRID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))],
+                ['',
+                 'CUR',
+                 'argument',
+                 (102, 22, 38, 0, 0, ('IN', 'OUT'))]
+                ]
+               ],
+              ['',
+               'FINDP',
+               'procedure', [
+                ['',
+                 'EMPID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))],
+                ['',
+                 'EMPNAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('OUT',))]
+                ]
+               ],
+              ['',
+               'FINDR',
+               'procedure', [
+                ['',
+                 'EMPID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))],
+                ['',
+                 'MGRID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN', 'OUT'))]
+                ]
+               ],
+              ['',
+               'FINDY',
+               'procedure', [
+                ['',
+                 'EMPID',
+                 'argument',
+                 (2, 22, 38, 0, 0, ('IN',))],
+                ['',
+                 'EMPNAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('OUT',))],
+                ['',
+                 'EJOB',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('IN', 'OUT'))]
+                ]
+               ],
+              ['',
+               'NUM',
+               'procedure', [
+                ['',
+                 'VALUE',
+                 'argument',
+                 (2, 22, 0, 0, 0, ('IN', 'OUT'))]
+                ]
+               ],
+              ['',
+               'RETURNTAB',
+               'procedure', [
+                ['',
+                 'POEM',
+                 'argument',
+                 (251, 0, 0, 0, 0, ('OUT',),
+                  ['',
+                   None,
+                   'argument',
+                   (1, 20, 0, 0, 0, ('OUT',))])
+                 ]
+                ]
+               ],
+              ['',
+               'TAKETAB',
+               'procedure',
+               [['',
+                 'IDS',
+                 'argument',
+                 (251, 0, 0, 0, 0, ('IN',),
+                  ['', None, 'argument', (1, 20, 0, 0, 0, ('IN',))])
+                 ]
+                ]],
+              ['',
+               'TESTI',
+               'procedure',
+               [['',
+                 'NAME',
+                 'argument',
+                 (1, 0, 0, 0, 0, ('IN',))
+                 ],
+                ['', 'ID', 'argument', (2, 22, 38, 0, 0, ('IN',))]]]
+              ]],
+             'EMP_ACTIONS.EMPCUR': [
+               '',
+               'EMPCUR',
+               'procedure',
+               [['', 'CSR', 'argument', (102, 0, 0, 0, 0, ('OUT',))]]],
+             'EMP_ACTIONS.FINDMGR': [
+               '',
+               'FINDMGR',
+               'procedure',
+               [['', 'MGRID', 'argument', (2, 22, 38, 0, 0, ('IN',))],
+                ['', 'CUR', 'argument', (102, 22, 38, 0, 0, ('IN', 'OUT'))]]],
+             'EMP_ACTIONS.TESTI': [
+               '',
+               'TESTI',
+               'procedure',
+               [['', 'NAME', 'argument', (1, 0, 0, 0, 0, ('IN',))],
+                ['', 'ID', 'argument', (2, 22, 38, 0, 0, ('IN',))]]],
+             'EMP_ACTIONS.FINDEMPBYNAME': [
+               '',
+               'FINDEMPBYNAME',
+               'procedure',
+               [['', 'NAME', 'argument', (1, 0, 0, 0, 0, ('IN',))],
+                ['', 'ID', 'argument', (2, 22, 0, 0, 0, ('OUT',))]]],
+             'EMP_ACTIONS.NUM': [
+               '',
+               'NUM',
+               'procedure',
+               [['', 'VALUE', 'argument', (2, 22, 0, 0, 0, ('IN', 'OUT'))]]],
+             'EMP_ACTIONS.FIND': [
+               '',
+               'FIND',
+               'function',
+               [['', None, 'argument', (1, 0, 0, 0, 0, ('OUT',))],
+                ['', 'EMPID', 'argument', (2, 22, 38, 0, 0, ('IN',))]]],
+             'EMP_ACTIONS.FINDP': [
+               '',
+               'FINDP',
+               'procedure',
+               [['', 'EMPID', 'argument', (2, 22, 38, 0, 0, ('IN',))],
+                ['', 'EMPNAME', 'argument', (1, 0, 0, 0, 0, ('OUT',))]]],
+             'EMP_ACTIONS.TAKETAB': [
+               '',
+               'TAKETAB',
+               'procedure',
+               [['',
+                 'IDS',
+                 'argument',
+                 (251, 0, 0, 0, 0, ('IN',),
+                  ['', None, 'argument', (1, 20, 0, 0, 0, ('IN',))])]]]}
+            )
+
+    def test_callproc(self):
+        
+        find = self.db.procedure.emp_actions.find
+
+        self.failUnless(
+            isinstance(find,
+                       DCOracle2.DCOracle2.procedure)
+            )
+
+        self.assertEqual(
+            dir(find),
+            ['__doc__', '__name__', '_argList', '_cursor', '_description', '_exec', '_schema']
+            )
+
+        self.assertEqual(find(7902),'FORD')
+
+        self.assertEqual(self.db.procedure.emp_actions.findp(7902),'FORD')
+
+    def test_callproc2(self):
+        
+        findy = self.db.procedure.emp_actions.findy
+        self.assertEqual(findy(7902,"Manager"),['FORD','ANALYST'])
+
+    def test_doc1(self):
+        
+        self.assertEqual(
+            getattr(self.c.procedure,self.username.lower()).emp_actions.find.__doc__,
+            'function %s.EMP_ACTIONS.FIND returns OUT VARCHAR2, has arguments:'
+            '\n\tEMPID IN NUMBER\n' % self.username
+            )
+
+    def test_doc2(self):
+
+        self.assertEqual(
+            getattr(self.c.procedure,self.username.lower()).emp_actions.__doc__,
+            'package %s.EMP_ACTIONS contains:'
+            '\n\tprocedure EMPCUR has arguments:'
+            '\n\t\tCSR OUT REF CURSOR'
+            '\n\tfunction FIND returns OUT VARCHAR2, has arguments:'
+            '\n\t\tEMPID IN NUMBER'
+            '\n\tprocedure FINDEMPBYNAME has arguments:'
+            '\n\t\tNAME IN VARCHAR2'
+            '\n\t\tID OUT NUMBER'
+            '\n\tfunction FINDEMPBYNAMEI returns OUT NUMBER, has arguments:'
+            '\n\t\tNAME IN VARCHAR2'
+            '\n\tprocedure FINDMGR has arguments:'
+            '\n\t\tMGRID IN NUMBER'
+            '\n\t\tCUR IN OUT REF CURSOR'
+            '\n\tprocedure FINDP has arguments:'
+            '\n\t\tEMPID IN NUMBER'
+            '\n\t\tEMPNAME OUT VARCHAR2'
+            '\n\tprocedure FINDR has arguments:'
+            '\n\t\tEMPID IN NUMBER'
+            '\n\t\tMGRID IN OUT NUMBER'
+            '\n\tprocedure FINDY has arguments:'
+            '\n\t\tEMPID IN NUMBER'
+            '\n\t\tEMPNAME OUT VARCHAR2'
+            '\n\t\tEJOB IN OUT VARCHAR2'
+            '\n\tprocedure NUM has arguments:'
+            '\n\t\tVALUE IN OUT NUMBER'
+            '\n\tprocedure RETURNTAB has arguments:'
+            '\n\t\tPOEM OUT TABLE OF T VARCHAR2'
+            '\n\n\tprocedure TAKETAB has arguments:'
+            '\n\t\tIDS IN TABLE OF  VARCHAR2'
+            '\n\n\tprocedure TESTI has arguments:'
+            '\n\t\tNAME IN VARCHAR2'
+            '\n\t\tID IN NUMBER\n' % self.username
+            )
 
+if __name__ == '__main__':
+    unittest.main()
 


=== Products/DCOracle2/test/test8.py 1.5 => 1.6 ===
--- Products/DCOracle2/test/test8.py:1.5	Mon Aug 27 15:12:44 2001
+++ Products/DCOracle2/test/test8.py	Thu Oct 30 12:06:34 2003
@@ -1,35 +1,87 @@
-
 # This assumes that the procdef.sql script has been run
-
-import DCOracle2
 import common
-import sys
-
-#r = sys.stdin.read()
-
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
-#bao = db.BindingArray(10, 64, 'SQLT_STR')
-
-#print len(bao)
-
-#c.execute("begin :1 := emp_actions.find(7902); end;", bao)
-
-#print len(bao)
-#print bao[0]
-
-print c.execute("begin emp_actions.testi(:1, 5); end;", "Mavra Chang")
-
-bao1 = db.BindingArray(1, 32, 1)
-bao1[0] = DCOracle2.TypeCoercion("Fred Flintstone",1)
-
-print c.execute("begin emp_actions.testi(:1, 4); end;", bao1)
-print bao1[0]
-
-bao1 = db.BindingArray(1,32,5)
-bao2 = db.BindingArray(1,32,5)
-bao2[0] = "manager"
+import DCOracle2
+import unittest
 
-print c.execute("begin emp_actions.findy(7902, :1, :2); end;", bao1, bao2)
-print bao1[0]
-print bao2[0]
+class test_bindingarrays(common.TestCase):
+    
+    def test_function(self):
+
+        self.assertEqual(
+            self.c.execute('begin emp_actions.testi(:1, 5); end;', "Mavra Chang"),
+            8
+            )
+        
+    def test_BindingArray(self):
+        
+        bao1 = self.db.BindingArray(1, 32, 1)
+        bao1[0] = DCOracle2.TypeCoercion("Fred Flintstone",1)
+    
+        self.assertEqual(
+            self.c.execute("begin emp_actions.testi(:1, 4); end;", bao1),
+            8
+            )
+        
+        self.assertEqual(bao1[0],'Fred Flintstone')
+
+    def test_2BindingArrays(self):
+
+        bao1 = self.db.BindingArray(1,32,5)
+        bao2 = self.db.BindingArray(1,32,5)
+        bao2[0] = "manager"
+
+        self.assertEqual(
+            self.c.execute("begin emp_actions.findy(7902, :1, :2); end;", bao1, bao2),
+            8
+            )
+        
+        self.assertEqual(bao1[0],'FORD')
+        self.assertEqual(bao2[0],'ANALYST')
+
+    def test_manyBindingArrays(self):
+
+        bao = self.db.BindingArray(10,20,'SQLT_STR')
+        bao[0] = 'Mary'
+        bao[1] = 'Had'
+        bao[2] = 'A'
+        bao[3] = 'Little'
+        bao[4] = 'Lamb'
+
+        c = self.c
+
+        self.assertEqual(
+            c.execute("begin emp_actions.taketab(:1); end;", bao),
+            8
+            )
+
+        self.assertEqual(
+            c.procedures.emp_actions.taketab(bao),
+            []
+            )
+
+        self.assertEqual(
+            c.procedures.emp_actions.taketab(['Mary','had','a','little','lamb']),
+            []
+            )
+
+        self.assertEqual(
+            c.procedures.emp_actions.returntab(),
+            ['Mary', 'had', 'a', 'little', 'lamb']
+            )
+
+    def test_tab(self):
+
+        c = self.c
+
+        tabin = c.procedure.emp_actions.taketab
+
+        invars = self.db.BindingArray(20, 20, 'SQLT_STR')
+
+        invars[0] = '123'
+        invars[1] = '456'
+
+        self.assertEqual(tabin(invars),[])
+        
+if __name__ == '__main__':
+    unittest.main()
+        


=== Products/DCOracle2/test/test7.py 1.1 => 1.2 ===
--- Products/DCOracle2/test/test7.py:1.1	Mon Nov 13 15:50:11 2000
+++ Products/DCOracle2/test/test7.py	Thu Oct 30 12:06:34 2003
@@ -1,9 +1,135 @@
-#
+import common
+import unittest
 
-import DCOracle2
-from pprint import pprint 
+class test_describe(common.TestCase):
 
-db = DCOracle2.connect('zoracle/zope')
-d = db.describe('zodb_methods')
+    def test_describe(self):
+        result = self.db.describe('EMP')
 
-pprint(d)
+        # delete stuff which can change across setups here
+        del result['OCI_ATTR_OBJ_ID']        
+        del result['OCI_ATTR_OBJID']
+        del result['OCI_ATTR_OBJ_SCHEMA']
+        
+        expected = {
+            'OCI_ATTR_CLUSTERED': 0,
+            'OCI_ATTR_PTYPE': 1,
+            'OCI_ATTR_TABLESPACE': 0,
+            'OCI_ATTR_NUM_COLS': 8,
+            'OCI_ATTR_INDEX_ONLY': 0,
+            'OCI_ATTR_IS_TEMPORARY': 0,
+            'OCI_ATTR_OBJ_NAME': 'EMP',
+            'OCI_ATTR_PARTITIONED': 0,
+            'OCI_ATTR_LIST_COLUMNS': [
+                {'OCI_ATTR_DATA_TYPE': 2,
+                 'OCI_ATTR_SCALE': 0,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 0,
+                 'OCI_ATTR_PRECISION': 4,
+                 'OCI_ATTR_NAME': 'EMPNO',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 0,
+                 'OCI_ATTR_CHARSET_ID': 0,
+                 'OCI_ATTR_DATA_SIZE': 22},
+                {'OCI_ATTR_DATA_TYPE': 1,
+                 'OCI_ATTR_SCALE': 0,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 1,
+                 'OCI_ATTR_PRECISION': 0,
+                 'OCI_ATTR_NAME': 'ENAME',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 1,
+                 'OCI_ATTR_DATA_SIZE': 10},
+                {'OCI_ATTR_DATA_TYPE': 1,
+                 'OCI_ATTR_SCALE': 0,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 1,
+                 'OCI_ATTR_PRECISION': 0,
+                 'OCI_ATTR_NAME': 'JOB',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 1,
+                 'OCI_ATTR_DATA_SIZE': 9},
+                {'OCI_ATTR_DATA_TYPE': 2,
+                 'OCI_ATTR_SCALE': 0,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 0,
+                 'OCI_ATTR_PRECISION': 4,
+                 'OCI_ATTR_NAME': 'MGR',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 0,
+                 'OCI_ATTR_DATA_SIZE': 22},
+                {'OCI_ATTR_DATA_TYPE': 12,
+                 'OCI_ATTR_SCALE': 0,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 0,
+                 'OCI_ATTR_PRECISION': 0,
+                 'OCI_ATTR_NAME': 'HIREDATE',
+                 'OCI_ATTR_PTYPE': 9, 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 0,
+                 'OCI_ATTR_DATA_SIZE': 7},
+                {'OCI_ATTR_DATA_TYPE': 2,
+                 'OCI_ATTR_SCALE': 2,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 0,
+                 'OCI_ATTR_PRECISION': 7,
+                 'OCI_ATTR_NAME': 'SAL',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 0,
+                 'OCI_ATTR_DATA_SIZE': 22},
+                {'OCI_ATTR_DATA_TYPE': 2,
+                 'OCI_ATTR_SCALE': 2,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 0,
+                 'OCI_ATTR_PRECISION': 7,
+                 'OCI_ATTR_NAME': 'COMM',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 0,
+                 'OCI_ATTR_DATA_SIZE': 22},
+                {'OCI_ATTR_DATA_TYPE': 2,
+                 'OCI_ATTR_SCALE': 0,
+                 'OCI_ATTR_SCHEMA_NAME': None,
+                 'OCI_ATTR_CHARSET_FORM': 0,
+                 'OCI_ATTR_PRECISION': 2,
+                 'OCI_ATTR_NAME': 'DEPTNO',
+                 'OCI_ATTR_PTYPE': 9,
+                 'OCI_ATTR_IS_NULL': 1,
+                 'OCI_ATTR_CHARSET_ID': 0,
+                 'OCI_ATTR_DATA_SIZE': 22}
+                ],
+            }
+
+        incorrect = []
+        not_present = []
+        for key,value in expected.items():
+            try:
+                found = result[key]
+                if found!=value:
+                    incorrect.append((key,value,found))
+                del result[key]
+            except KeyError:
+                not_present.append(key)
+        extra = result.keys()
+
+        if incorrect or not_present or extra:
+            self.fail("""
+The following keys were incorrect:
+%s
+
+The following keys were not present:
+%s
+
+The following keys were found in the result but were not expected:
+%s
+""" % (
+         '\n'.join(['%s: found:%s expected:%s' % (i[0],i[2],i[1]) for i in incorrect]),
+         '\n'.join(not_present),
+         '\n'.join(extra),
+         ))
+            
+if __name__ == '__main__':
+    unittest.main()


=== Products/DCOracle2/test/test6.py 1.3 => 1.4 ===
--- Products/DCOracle2/test/test6.py:1.3	Tue Mar 27 09:33:57 2001
+++ Products/DCOracle2/test/test6.py	Thu Oct 30 12:06:34 2003
@@ -1,8 +1,5 @@
-#!/usr/bin/python
-
-import string
-import DCOracle2
 import common
+import unittest
 
 custtable = (('Anonymous',1.9,None,None), \
     ('toolco',1.5,(46,),None), \
@@ -10,60 +7,82 @@
     ('misty',1.4,(None,),('misting',)) \
     )
 
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
+class test_insert(common.TestCase):
 
-try:
-    c.execute("drop table partlist")
-except DCOracle2.DatabaseError:
-    pass
+    tables_to_drop = ('partlist','partcust')
+    
+    def test_insert_many(self):
 
-c.execute("create table partlist (part varchar2(62), partno integer, quantity integer, price number(10,2)) tablespace users")
+        c = self.c
+        
+        c.execute("create table partlist (part varchar2(62), partno integer, quantity integer, price number(10,2)) tablespace users")
 
-file = open("namegen.out","r")
+        file = open("namegen.out","r")
 
-v = []
+        v = []
 
-for l in file.readlines():
+        for l in file.readlines():
 
-    (part, partno, quantity, price) = string.split(string.strip(l),',')
+            (part, partno, quantity, price) = l.strip().split(',')
 
-    v.append((part, partno, quantity, price))
+            v.append((part, partno, quantity, price))
 
-file.close()
+        file.close()
 
-c.executemany("insert into partlist (part, partno, quantity, price) values (:1,:2,:3,:4)", v)
+        c.executemany("insert into partlist (part, partno, quantity, price) values (:1,:2,:3,:4)", v)
 
-db.commit()
+        self.db.commit()
 
-c.execute("select part, partno, quantity, price from partlist order by partno")
+        c.execute("select part, partno, quantity, price from partlist order by partno")
 
-results = c.fetchall()
+        results = c.fetchall()
 
-try:
-    c.execute("drop table partcust")
-except DCOracle2.DatabaseError:
-    pass
+        c.execute("create table partcust (customer varchar2(32), partno integer, price number(10,2)) tablespace users")
 
-c.execute("create table partcust (customer varchar2(32), partno integer, price number(10,2)) tablespace users")
+        for r in results:
+            (part, partno, quantity, price) = r
+    
+            for (customer,factor,baseparts,pattern) in custtable:
+                cfactor =  0
+                if baseparts is not None:
+                    for p in baseparts:
+                        if int(partno / 1000) == p: cfactor = factor
+                else:
+                    cfactor = factor
+                if pattern is not None:
+                    for pat in pattern:
+                        if part and part.find(pat) >= 0:
+                            cfactor = factor
+                if price is not None:
+                    cprice = float("%8.2f" % (price * cfactor))
+                else:
+                    cprice = 0.0
+                if (cprice > 0.0):
+                    c.execute("insert into partcust (customer, partno, price) values (:1,:2,:3)", customer, partno, cprice)
 
-for r in results:
-    (part, partno, quantity, price) = r
+        self.db.commit()
 
-    for (customer,factor,baseparts,pattern) in custtable:
-        cfactor =  0
-        if baseparts is not None:
-            for p in baseparts:
-                if int(partno / 1000) == p: cfactor = factor
-        else:
-            cfactor = factor
-        if pattern is not None:
-            for pat in pattern:
-                if string.find(part,pat) >= 0:
-                    cfactor = factor
-        cprice = float("%8.2f" % (price * cfactor)) 
-        if (cprice > 0.0):
-            c.execute("insert into partcust (customer, partno, price) values (:1,:2,:3)", customer, partno, cprice)
+    def test_insert(self):
+
+        c = self.c
+
+        c.execute('select * from test')
+
+        old_len = len(c.fetchall())
+
+        c.execute('insert into test values (:1, :2, NULL)',
+                  (('Fred Flintstone', 'Mavra Chang'), (4,5)))
+
+        c.execute('select * from test')
+
+        r = c.fetchall()
+
+        self.assertEqual(len(r),old_len+2)
+
+        self.assertEqual(
+            r[-2:],
+            [['Fred Flintstone', 4, ''], ['Mavra Chang', 5, '']]
+            )
 
-db.commit()
-DCOracle2.traceback(format=1)
+if __name__ == '__main__':
+        unittest.main()


=== Products/DCOracle2/test/test5.py 1.5 => 1.6 ===
--- Products/DCOracle2/test/test5.py:1.5	Tue Aug  7 13:25:38 2001
+++ Products/DCOracle2/test/test5.py	Thu Oct 30 12:06:34 2003
@@ -1,69 +1,39 @@
-#
-
 import DCOracle2
-import time
 import common
+import unittest
 
-names = (
-    ("Matt Kromer", 1),
-    ("Jens Vagelpohl", 2),
-    ("Chris Petrilli", 3)
-    )
-
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
-
-
-try:
-    c.execute("drop table blobtest")
-except OracleError:
-    pass
-
-c.execute("create table blobtest (name varchar2(32), id integer, photo blob) tablespace users")
-
-c.executemany("insert into blobtest values (:1, :2, EMPTY_BLOB())", names)
-   
-c.execute("insert into blobtest values (:1, :2, EMPTY_BLOB())", \
-    "Shane Hathaway", 4)
-
-c.execute("insert into blobtest values (:1, :2, EMPTY_BLOB())", \
-    "Shane Hathaway #2", 5)
-
-f = open("/home/matt/graphics/shane-007.jpg")
-
-fredpic = f.read()
-
-l = len(fredpic)
-print "Inserting %d bytes" % l
-
-f.close()
-
-start = time.time()
-c.execute("select * from blobtest where id>3 for update")
-
-for r in c.fetchall():
-
-    lob = r[2]
-
-    lob.write(fredpic)
-
-stop = time.time()
-db.commit()
-
-print "Inserted %d bytes in %lf secs at %9.3lf Kbytes/sec" % (l*2, stop-start, l/(stop-start)/512)
-
-
-try:
-    c.execute("select * from blobtest where id>3")
-
-    for r in c.fetchall():
-
-        lob = r[2]
-
-        pic = lob.read()
+class test_blob(common.TestCase):
 
-        assert(pic == fredpic)
-        print "Photo %s, #%d OK" % (r[0], r[1])
-except DCOracle2.DatabaseError:
-    print DCOracle2.traceback(format=1)
+    tables_to_drop = ('blobtest',)
+    
+    def test_blob(self):
+        c = self.c
+        c.execute("create table blobtest (name varchar2(32), id integer, photo blob) tablespace users")
+        c.execute("insert into blobtest values (:1, :2, EMPTY_BLOB())", \
+                  "Shane Hathaway", 4)
+        c.execute("insert into blobtest values (:1, :2, EMPTY_BLOB())", \
+                  "Shane Hathaway #2", 5)
+
+        lump = self._getBinary(200)
+
+        c.execute("select * from blobtest where id>3 for update")
+
+        for r in c.fetchall():
+            
+            lob = r[2]
+            lob.write(lump)
+
+        self.db.commit()
+
+        c.execute("select * from blobtest where id>3")
+        for r in c.fetchall():
+
+            lob = r[2]
+            pic = lob.read()            
+            self.assertEqual(pic,
+                             lump,
+                             'selected binary data different from inserted binary data')
+            
+if __name__ == '__main__':
+    unittest.main()
 


=== Products/DCOracle2/test/test4.py 1.6 => 1.7 ===
--- Products/DCOracle2/test/test4.py:1.6	Tue Aug  7 13:25:38 2001
+++ Products/DCOracle2/test/test4.py	Thu Oct 30 12:06:34 2003
@@ -1,77 +1,30 @@
-#
-
-import DCOracle2
-import time
 import common
+import DCOracle2
+import unittest
 
-names = (
-    ("Matt Kromer", 1),
-    ("Jens Vagelpohl", 2),
-    ("Chris Petrilli", 3)
-    )
-
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
-
-try:
-    c.execute('drop table longone')
-except DCOracle2.DatabaseError: pass
-
-c.execute('create table longone (name varchar2(64), id number(9), photo long raw)')
-
-c.executemany('insert into longone (name, id) values (:1, :2)', names)
-
-db.commit()
-
-c.execute("select * from longone")
-
-r = c.fetchone()
-
-#print r
-
-f = open("/home/matt/graphics/shane-007.jpg")
-
-fredpic = f.read()
-
-
-l = len(fredpic)
-print "Inserting %d bytes" % l
-
-f.close()
-
-start = time.time()
-c.execute("insert into longone (name, id, photo) values (:1, :2, :3)", \
-    "Shane Hathaway", 4, DCOracle2.Binary(fredpic))
-
-
-c.execute("insert into longone (name, id, photo) values (:1, :2, :3)", \
-    "Shane Hathaway #2", 5, DCOracle2.Binary(fredpic))
-
-stop = time.time()  
-
-print "Inserted %d bytes in %lf secs at %9.3lf Kbytes/sec\n" % (l*2, stop-start, l/(stop-start)/512)
+class test_raw(common.TestCase):
 
-start = time.time()
-c.execute("select photo from longone where id > 3")
+    tables_to_drop = ('test',)
+    
+    def test_raw(self):
 
-r = c.fetchone()
-stop = time.time()  
+        lump = self._getBinary(200)
+        
+        c = self.c
 
-if r[0] != fredpic:
-    print "whoops!  did not get back what we put in!"
-else:
-    print "Fetched %d bytes in %lf secs at %9.3lf Kbytes/sec\n" % (l, stop-start, l/(stop-start)/1024)
+        c.execute('create table test (name varchar2(64), id number(9), photo long raw)')
 
+        c.execute("insert into test (name, id, photo) values (:1, :2, :3)", \
+                  "Shane Hathaway", 4, DCOracle2.Binary(lump))
 
-start = time.time()
 
-r = c.fetchone()
-stop = time.time()  
+        c.execute("select photo from test where id > 3")
 
-if r[0] != fredpic:
-    print "whoops!  did not get back what we put in!"
-else:
-    print "Fetched %d bytes in %lf secs at %9.3lf Kbytes/sec\n" % (l, stop-start, l/(stop-start)/1024)
+        self.assertEqual(c.fetchone()[0],
+                         lump,
+                         'selected binary data different from inserted binary data')
 
+        self.db.rollback()
 
-db.rollback()
+if __name__ == '__main__':
+    unittest.main()


=== Products/DCOracle2/test/test3.py 1.6 => 1.7 ===
--- Products/DCOracle2/test/test3.py:1.6	Tue Mar 27 09:33:57 2001
+++ Products/DCOracle2/test/test3.py	Thu Oct 30 12:06:34 2003
@@ -1,7 +1,5 @@
-#
-
-import DCOracle2
 import common
+import unittest
 
 names = (
     ("Matt Kromer", 1),
@@ -9,54 +7,57 @@
     ("Chris Petrilli", 3)
     )
 
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
-
-
-print "Dropping table"
-
-try:
-    c.execute("drop table test")
-except:
-    pass
-
-
-print "Creating table" 
-c.execute("create table test ( name varchar2(64), id number(9) )")
-
-print "Inserting into test"
-c.executemany("insert into test (name, id) values (:1, :2)", names)
-
-#print DCOracle2.traceback(format=1)
-
-print "Selecting from test"
-c.execute("select * from test")
-
-print "Describing test"
-print list(c.description)
-
-c.arraysize = 20
-
-print "Printing test"
-r = c.fetchall()
-print r
-
-print "Commiting test"
-db.commit()
-
-print "Adding one more entry"
-c.execute("insert into test (name, id) values (:1, :2)", "Fred Flintstone", 4)
-
-print "Printing test"
-c.execute("select * from test")
-r = c.fetchall()
-print r
-
-print "Rolling back last entry"
-db.rollback()
+class test_basics(common.TestCase):
 
-print "Printing test"
-c.execute("select * from test")
-r = c.fetchall()
-print r
+    tables_to_drop = ('test',)
+    
+    def test_basics(self):
+        c = self.c
+
+        c.execute("create table test ( name varchar2(64), id number(9) )")
+
+        # Inserting into test
+        c.executemany("insert into test (name, id) values (:1, :2)", names)
+
+        # Selecting from test
+        c.execute("select * from test")
+
+        # Describing test
+        self.assertEqual(list(c.description),
+                         [('NAME', 'VARCHAR2', 64, 64, 0, 0, 1),
+                          ('ID', 'NUMBER', 22, 22, 9, 0, 1)])
+        c.arraysize = 20
+
+        # Checking test
+        
+        self.assertEqual(c.fetchall(),
+                         [['Matt Kromer', 1],
+                          ['Jens Vagelpohl', 2],
+                          ['Chris Petrilli', 3]])
+
+        # Commiting test
+        self.db.commit()
+
+        # Adding one more entry
+        c.execute("insert into test (name, id) values (:1, :2)", "Fred Flintstone", 4)
+
+        # re-checking test
+        c.execute("select * from test")
+        self.assertEqual(c.fetchall(),
+                         [['Matt Kromer', 1],
+                          ['Jens Vagelpohl', 2],
+                          ['Chris Petrilli', 3],
+                          ['Fred Flintstone', 4]])
+
+        # rolling back last entry"
+        self.db.rollback()
+
+        # checking test yet again
+        c.execute("select * from test")
+        self.assertEqual(c.fetchall(),
+                         [['Matt Kromer', 1],
+                          ['Jens Vagelpohl', 2],
+                          ['Chris Petrilli', 3]])
 
+if __name__ == '__main__':
+    unittest.main()


=== Products/DCOracle2/test/test2.py 1.4 => 1.5 ===
--- Products/DCOracle2/test/test2.py:1.4	Tue Mar 27 09:33:57 2001
+++ Products/DCOracle2/test/test2.py	Thu Oct 30 12:06:34 2003
@@ -1,18 +1,49 @@
-#
-
-import DCOracle2
 import common
+import unittest
 
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
-c.execute("select * from emp")
-print list(c.description)
-
-c.arraysize = 20
+from DCOracle2.dco2 import OracleDate
 
-r = c.fetchall()
+class test_DCOracle2_connect(common.TestCase):
 
-print r
+    def setUp(self):
+        common.TestCase.setUp(self)
+        self.c.execute("select * from emp")
+
+    def test_cursorDescription(self):
+        self.assertEqual(list(self.c.description),
+                         [('EMPNO', 'NUMBER', 22, 22, 4, 0, 0),
+                          ('ENAME', 'VARCHAR2', 10, 10, 0, 0, 1),
+                          ('JOB', 'VARCHAR2', 9, 9, 0, 0, 1),
+                          ('MGR', 'NUMBER', 22, 22, 4, 0, 1),
+                          ('HIREDATE', 'DATE', 7, 7, 0, 0, 1),
+                          ('SAL', 'NUMBER', 22, 22, 7, 2, 1),
+                          ('COMM', 'NUMBER', 22, 22, 7, 2, 1),
+                          ('DEPTNO', 'NUMBER', 22, 22, 2, 0, 1)])
+        
+    def test_fetchall(self):
+        self.c.arraysize = 20
+
+        r = self.c.fetchall()
+        
+        self.assertEqual(r,
+                         [
+            [7369, 'SMITH', 'CLERK', 7902, OracleDate(1980,12,17,0,0,0), 800.0, None, 20],
+            [7499, 'ALLEN', 'SALESMAN', 7698, OracleDate(1981,2,20,0,0,0), 1600.0, 300.0, 30],
+            [7521, 'WARD', 'SALESMAN', 7698, OracleDate(1981,2,22,0,0,0), 1250.0, 500.0, 30],
+            [7566, 'JONES', 'MANAGER', 7839, OracleDate(1981,4,02,0,0,0), 2975.0, None, 20],
+            [7654, 'MARTIN', 'SALESMAN', 7698, OracleDate(1981,9,28,0,0,0), 1250.0, 1400.0, 30],
+            [7698, 'BLAKE', 'MANAGER', 7839, OracleDate(1981,5,1,0,0,0), 2850.0, None, 30],
+            [7782, 'CLARK', 'MANAGER', 7839, OracleDate(1981,6,9,0,0,0), 2450.0, None, 10],
+            [7788, 'SCOTT', 'ANALYST', 7566, OracleDate(1987,4,19,0,0,0), 3000.0, None, 20],
+            [7839, 'KING', 'PRESIDENT', None, OracleDate(1981,11,17,0,0,0), 5000.0, None, 10],
+            [7844, 'TURNER', 'SALESMAN', 7698, OracleDate(1981,9,8,0,0,0), 1500.0, 0.0, 30],
+            [7876, 'ADAMS', 'CLERK', 7788, OracleDate(1987,5,23,0,0,0), 1100.0, None, 20],
+            [7900, 'JAMES', 'CLERK', 7698, OracleDate(1981,12,3,0,0,0), 950.0, None, 30],
+            [7902, 'FORD', 'ANALYST', 7566, OracleDate(1981,12,3,0,0,0), 3000.0, None, 20],
+            [7934, 'MILLER', 'CLERK', 7782, OracleDate(1982,1,23,0,0,0), 1300.0, None, 10]
+            ])
 
-d = r[0][4]
+        self.assertEqual(str(r[0][4]),'1980-12-17 00:00:00')
 
+if __name__ == '__main__':
+    unittest.main()


=== Products/DCOracle2/test/test11.py 1.2 => 1.3 ===
--- Products/DCOracle2/test/test11.py:1.2	Mon Feb 25 11:21:06 2002
+++ Products/DCOracle2/test/test11.py	Thu Oct 30 12:06:34 2003
@@ -1,35 +1,75 @@
-
+import common
 import DCOracle2
 import time
-import common
+import unittest
+
+from DCOracle2.dco2 import OracleDate
+
+class test_datetime(common.TestCase):
+
+    tables_to_drop = ('datetest',)
+
+    def test_DateConversion(self):
+
+        currentdatetime = time.time()
+        
+        DCOracle2.registerDateConversion(lambda x: ".date(%s)." % x)
+        try:
+            c = self.c
+
+            c.execute("create table datetest (id integer, stamp date)")
+
+            now = DCOracle2.DateFromTicks(currentdatetime)
 
+            c.execute("insert into datetest(id, stamp) values(:1, :2)", 1, now)
 
-DCOracle2.registerDateConversion(lambda x: ".date(%s)." % x)
+            self.db.commit()
 
-db = DCOracle2.connect(common.getConnectionString())
+            c.execute("select * from datetest where id=1")
 
-#r = sys.stdin.read()
+            r = c.fetchone()
 
-c = db.cursor()
+            saved = r[1]
 
-try:
-    c.execute("drop table datetest")
-except DCOracle2.DatabaseError:
-    pass
+            stime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(currentdatetime))
+            self.assertEqual(str(now),stime)
+            self.assertEqual(saved,'.date('+stime+').')
+        finally:
+            DCOracle2.registerDateConversion(None)
 
-c.execute("create table datetest (id integer, stamp date)")
+    def test_DateInsertion(self):
 
-now = DCOracle2.DateFromTicks(time.time())
+        c = self.c
 
-c.execute("insert into datetest(id, stamp) values(:1, :2)", 1, now)
+        c.execute('create table datetest (name varchar2(64), when date)')
 
-db.commit()
+        day = 60 * 60 * 24
+        now = time.time()
+        tomorrow = now+1*day
+        yesterday = now-1*day
+        rsn = now+14*day
+        data = (
+                ("Now", DCOracle2.DateFromTicks(now)),
+                    ("Tomorrow", DCOracle2.DateFromTicks(tomorrow)),
+                    ("Yesterday", DCOracle2.DateFromTicks(yesterday)),
+                    ("RSN", DCOracle2.DateFromTicks(rsn))
+                )
 
-c.execute("select * from datetest where id=1")
+        c.executemany('insert into datetest (name, when) values (:1, :2)', data)
 
-r = c.fetchone()
+        self.db.commit()
 
-saved = r[1]
+        c.execute('select * from datetest')
 
-print "Well: %s vs %s" % (now, saved)
+        self.assertEqual(
+            c.fetchall(),
+            [
+            ['Now', OracleDate(*time.localtime(now)[:6])],
+            ['Tomorrow', OracleDate(*time.localtime(tomorrow)[:6])],
+            ['Yesterday', OracleDate(*time.localtime(yesterday)[:6])],
+            ['RSN', OracleDate(*time.localtime(rsn)[:6])]
+            ]
+            )
 
+if __name__ == '__main__':
+    unittest.main()        


=== Products/DCOracle2/test/test10.py 1.3 => 1.4 ===
--- Products/DCOracle2/test/test10.py:1.3	Thu Mar 29 14:40:59 2001
+++ Products/DCOracle2/test/test10.py	Thu Oct 30 12:06:34 2003
@@ -1,26 +1,52 @@
-#
-
-import DCOracle2
 import common
-import sys
-
-db = DCOracle2.connect(common.getConnectionString())
-
-#r = sys.stdin.read()
-
-c = db.cursor()
-#c.execute('select ename, CURSOR(select ename, mgr from emp) from emp where empno=7902')
-
-#rs = c.fetchall()
-#for r in rs:
-#    c1 = r[1]
-#    print c1.fetchall()
-
-findmgr = db.procedure.emp_actions.findmgr
+import unittest
 
-c1 = db.cursor()
+from DCOracle2.dco2 import OracleDate
 
-c = findmgr(7839,c1)
+class test_cursors(common.TestCase):
 
-r = c1.fetchall()
-print r
+    def test_selectCursor(self):
+        c = self.c
+        c.execute('select ename, CURSOR(select ename, mgr from emp) from emp where empno=7902')
+
+        rs = c.fetchall()
+
+        self.assertEqual(len(rs),1)
+        c1 = rs[0][1]
+        self.assertEqual(c1.fetchall(),
+                         [
+            ['SMITH', 7902],
+            ['ALLEN', 7698],
+            ['WARD', 7698],
+            ['JONES', 7839],
+            ['MARTIN', 7698],
+            ['BLAKE', 7839],
+            ['CLARK', 7839],
+            ['SCOTT', 7566],
+            ['KING', None],
+            ['TURNER', 7698],
+            ['ADAMS', 7788],
+            ['JAMES', 7698],
+            ['FORD', 7566],
+            ['MILLER', 7782]
+            ])
+
+    def test_sp_cursor(self):
+                        
+        findmgr = self.db.procedure.emp_actions.findmgr
+
+        c1 = self.db.cursor()
+
+        c = findmgr(7839,c1)
+
+        self.assertEqual(c1.fetchall(),
+                         [
+            [7566, 'JONES', 'MANAGER', 7839, OracleDate(1981,4,2,0,0,0), 2975.0, None, 20],
+            [7698, 'BLAKE', 'MANAGER', 7839, OracleDate(1981,5,1,0,0,0), 2850.0, None, 30],
+            [7782, 'CLARK', 'MANAGER', 7839, OracleDate(1981,6,9,0,0,0), 2450.0, None, 10]
+            ])
+
+
+if __name__ == '__main__':
+    unittest.main()
+        


=== Products/DCOracle2/test/test1.py 1.2 => 1.3 ===
--- Products/DCOracle2/test/test1.py:1.2	Mon Mar  5 16:24:00 2001
+++ Products/DCOracle2/test/test1.py	Thu Oct 30 12:06:34 2003
@@ -1,16 +1,39 @@
+import common
 import DCOracle2.dco2
+import unittest
 
-db = DCOracle2.dco2.connect("scott","tiger","")
-c = db.cursor()
-c.prepare("select * from emp")
-c.execute()
-print list(c.describe())
-f = c.fetch(5)
-
-print f
-print f[0]
-print len(f[0])
+class test_dco2_connect(common.TestCase):
 
-print list(f[1])
+    def setUp(self):
 
-print f[0][1].value()
+        username, password, dbname = self._getConnDetails()
+        self.db = db = DCOracle2.dco2.connect(username,password,dbname)
+        c = db.cursor()
+        c.prepare("select * from EMP")
+        c.execute()
+        self.c = c
+        self.f = c.fetch(5)
+
+
+    def test_cursorDescribe(self):
+        self.assertEqual(list(self.c.describe()),
+                         [('EMPNO', 2, 22, 22, 4, 0, 0),
+                          ('ENAME', 1, 10, 10, 0, 0, 1),
+                          ('JOB', 1, 9, 9, 0, 0, 1),
+                          ('MGR', 2, 22, 22, 4, 0, 1),
+                          ('HIREDATE', 12, 7, 7, 0, 0, 1),
+                          ('SAL', 2, 22, 22, 7, 2, 1),
+                          ('COMM', 2, 22, 22, 7, 2, 1),
+                          ('DEPTNO', 2, 22, 22, 2, 0, 1)])
+
+    def test_result(self):
+        f = self.f
+        self.assertEqual(len(f),8)
+        self.assertEqual(len(f[0]),5)
+        self.failUnless(isinstance(f[0],DCOracle2.dco2.ResultSetType))
+        self.assertEqual(len(f[1]),5)
+        self.failUnless(isinstance(f[1][0],DCOracle2.dco2.ResultSetItemType))
+        self.assertEqual(self.f[0][1].value(),7499)
+
+if __name__ == '__main__':
+        unittest.main()


=== Products/DCOracle2/test/stest.py 1.1 => 1.2 ===
--- Products/DCOracle2/test/stest.py:1.1	Mon Oct 15 11:06:09 2001
+++ Products/DCOracle2/test/stest.py	Thu Oct 30 12:06:34 2003
@@ -1,27 +1,30 @@
-#
-# this test from Christopher Jenkins, looking for bad binds in Oracle 9i
-# 
-# 
-
-import DCOracle2
 import common
+import unittest
+
+class test_binds(common.TestCase):
+
+    tables_to_drop = ('stest',)
 
-db = DCOracle2.connect(common.getConnectionString())
-c = db.cursor()
+    def test_bad_binds_in_9i(self):
+        # this test from Christopher Jenkins, looking for bad binds in Oracle 9i
+        c = self.c
+        
+        c.execute('create table stest (s char(10))')
 
-try:
-    c.execute('drop table stest')
-except DCOracle2.DatabaseError: pass
+        l1 = [(None,),("hello",),(None,)]
+        l2 = [("",),("hello",),("",)]
 
-c.execute('create table stest (s char(10))')
+        stmt = "insert into stest values(:1)"
 
-l1 = [(None,),("hello",),(None,)]
-l2 = [("",),("hello",),("",)]
+        c.executemany(stmt, l1)
+        c.executemany(stmt, l2)
 
-stmt = "insert into stest values(:1)"
+        c.execute('select * from stest')
 
-c.executemany(stmt, l1)
-c.executemany(stmt, l2)
+        self.assertEqual(
+            c.fetchall(),
+            [[None], ['hello     '], [None], [''], ['hello     '], [None]]
+            )
 
-c.execute('select * from stest')
-print c.fetchall()
+if __name__ == '__main__':
+    unittest.main()




More information about the Zope-Checkins mailing list