From: brian z. <bz...@us...> - 2001-12-21 03:45:30
|
Update of /cvsroot/jython/jython/Lib/test/zxjdbc In directory usw-pr-cvs1:/tmp/cvs-serv27673 Modified Files: sptest.py test.xml zxtest.py Log Message: stored procedures/functions now return results Index: sptest.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/test/zxjdbc/sptest.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sptest.py 2001/12/17 03:45:38 1.1 --- sptest.py 2001/12/21 03:45:27 1.2 *************** *** 29,33 **** c.execute("create table plsqltest (x char(20))") c.execute("create or replace procedure procnone is begin insert into plsqltest values ('testing'); end;") ! c.execute("create or replace procedure procin (y char) is begin insert into plsqltest values (y); end;") c.execute("create or replace procedure procout (y out char) is begin y := 'tested'; end;") c.execute("create or replace procedure procinout (y out varchar, z in varchar) is begin insert into plsqltest values (z); y := 'tested'; end;") --- 29,33 ---- c.execute("create table plsqltest (x char(20))") c.execute("create or replace procedure procnone is begin insert into plsqltest values ('testing'); end;") ! c.execute("create or replace procedure procin (y in char) is begin insert into plsqltest values (y); end;") c.execute("create or replace procedure procout (y out char) is begin y := 'tested'; end;") c.execute("create or replace procedure procinout (y out varchar, z in varchar) is begin insert into plsqltest values (z); y := 'tested'; end;") *************** *** 64,134 **** finally: c.close() - - def testProcinout(self): - c = self.cursor() - try: - p = Procedure(c, "procinout") - stmt = p.prepareCall() - params = ["testing"] - params = p.normalizeParams(params) - - self.assertEquals(2, len(params)) - assert params[0] == p.PLACEHOLDER - assert params[1] == "testing" - finally: - if stmt: - stmt.close() - c.close() ! def testFuncout(self): c = self.cursor() try: ! p = Procedure(c, "funcout") ! stmt = p.prepareCall() ! stmt.execute() ! self.assertEquals("returned", stmt.getString(1).strip()) ! self.assertEquals("tested", stmt.getString(2).strip()) finally: - if stmt: - stmt.close() c.close() ! def testProcinoutCall(self): c = self.cursor() try: c.callproc("procinout", ("testing",)) ! assert c.fetchall() == None, "expected None" finally: c.close() ! def testFuncnoneCall(self): c = self.cursor() try: c.callproc("funcnone") ! assert c.fetchall() == None, "expected None" finally: c.close() ! def testFuncinCall(self): c = self.cursor() try: c.callproc("funcin", ("testing",)) ! assert c.fetchall() == None, "expected None" finally: c.close() ! def testFuncoutCall(self): c = self.cursor() try: c.callproc("funcout") ! assert c.fetchall() == None, "expected None" finally: c.close() ! def testRaisesalaryCall(self): c = self.cursor() try: c.callproc("raisesal", ("jython developer", 18000)) ! assert c.fetchall() == None, "expected None" finally: c.close() --- 64,131 ---- finally: c.close() ! def testProcin(self): c = self.cursor() try: ! c.callproc("procin", ("testProcin",)) ! self.assertEquals(None, c.fetchall()) ! c.execute("select * from plsqltest") ! self.assertEquals(1, len(c.fetchall())) finally: c.close() ! def testProcinout(self): c = self.cursor() try: c.callproc("procinout", ("testing",)) ! data = c.fetchone() ! assert data is not None, "data was None" ! self.assertEquals("tested", data[0]) finally: c.close() ! def testFuncnone(self): c = self.cursor() try: c.callproc("funcnone") ! data = c.fetchone() ! assert data is not None, "data was None" ! self.assertEquals(1, len(data)) ! self.assertEquals("tested", data[0]) finally: c.close() ! def testFuncin(self): c = self.cursor() try: c.callproc("funcin", ("testing",)) ! self.assertEquals(1, c.rowcount) ! data = c.fetchone() ! assert data is not None, "data was None" ! self.assertEquals(1, len(data)) ! self.assertEquals("testingtesting", data[0]) finally: c.close() ! def testFuncout(self): c = self.cursor() try: c.callproc("funcout") ! data = c.fetchone() ! assert data is not None, "data was None" ! self.assertEquals(2, len(data)) ! self.assertEquals("returned", data[0]) ! self.assertEquals("tested", data[1].strip()) finally: c.close() ! def testRaisesalary(self): c = self.cursor() try: c.callproc("raisesal", ("jython developer", 18000)) ! data = c.fetchone() ! assert data is not None, "data was None" ! self.assertEquals(1, len(data)) ! self.assertEquals(18000 + 100000, data[0]) finally: c.close() Index: test.xml =================================================================== RCS file: /cvsroot/jython/jython/Lib/test/zxjdbc/test.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test.xml 2001/12/17 03:45:38 1.2 --- test.xml 2001/12/21 03:45:27 1.3 *************** *** 2,6 **** <!-- - Jython Database Specification API 2.0 --- 2,5 ---- *************** *** 8,12 **** Copyright (c) 2001 brian zimmer <bz...@zi...> - --> --- 7,10 ---- Index: zxtest.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/test/zxjdbc/zxtest.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** zxtest.py 2001/12/17 03:45:38 1.2 --- zxtest.py 2001/12/21 03:45:27 1.3 *************** *** 301,305 **** assert self.has_table("floattable"), "missing attribute floattable" from java.math import BigDecimal ! values = map(lambda x, b=BigDecimal: b(x), [4.22, 123.44, 292.09, 33.2, 102.00, 445]) self._test_precision(self.table("floattable"), lambda x, y, b=BigDecimal: b(x).subtract(y).doubleValue(), values, "doubleValue") --- 301,305 ---- assert self.has_table("floattable"), "missing attribute floattable" from java.math import BigDecimal ! values = [BigDecimal(x).setScale(2, BigDecimal.ROUND_UP) for x in [4.22, 123.44, 292.09, 33.2, 102.00, 445]] self._test_precision(self.table("floattable"), lambda x, y, b=BigDecimal: b(x).subtract(y).doubleValue(), values, "doubleValue") *************** *** 308,312 **** assert self.has_table("floattable"), "missing attribute floattable" from java.math import BigDecimal ! values = map(lambda x, b=BigDecimal: b(x), [4.22, 123.44, 33.2, 102.00, 445, 292.09]) self._test_precision(self.table("floattable"), lambda x, y: x - y.doubleValue(), values, "doubleValue") --- 308,312 ---- assert self.has_table("floattable"), "missing attribute floattable" from java.math import BigDecimal ! values = [BigDecimal(x).setScale(2, BigDecimal.ROUND_UP) for x in [4.22, 123.44, 292.09, 33.2, 102.00, 445]] self._test_precision(self.table("floattable"), lambda x, y: x - y.doubleValue(), values, "doubleValue") |