From: David F. <dav...@us...> - 2006-06-28 10:06:39
|
Update of /cvsroot/myoledb/myoledb3/test In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv24895 Added Files: test_dbapi.py Log Message: added tests using dbapi, using either jtoolkit or j5 as PyADO driver --- NEW FILE: test_dbapi.py --- #!/usr/bin/env python """py.test tests for MyOLEDB using a Python DB-API compliant driver Will attempt to import various drivers and run tests on any imported successfully""" try: from jToolkit.data import PyADO as jToolkit_PyADO except ImportError: jToolkit_PyADO = None try: from j5.Database.ADO import PyADO as j5_PyADO except ImportError: j5_PyADO = None class MySqlADOTester: def setup_class(cls): cls.db = cls.setup_db() def teardown_class(cls): cls.db.close() def execute_query(self, query): cursor = self.db.cursor() cursor.execute(query) return cursor def test_simple(self): try: self.execute_query("drop table test_simple") except Exception, e: pass self.execute_query("create table test_simple(x text, y text)") self.execute_query("insert into test_simple(x, y) values('test', 'me')") results = self.execute_query("select x, y from test_simple").fetchall() assert results == [["test", "me"]] def test_count_type(self): try: self.execute_query("drop table test_count_type") except Exception, e: pass self.execute_query("create table test_count_type(x text, y text)") self.execute_query("insert into test_count_type(x, y) values('test', 'me')") results = self.execute_query("select count(*) from test_count_type").fetchall() assert results == [[1]] class Test_j5_ADO(MySqlADOTester): PyADO = j5_PyADO disabled = (j5_PyADO is None) def setup_db(cls): return cls.PyADO.connect(None, {"User ID": "mytest", "Password": "", "Data Source": "mytest"}, "MySQLProv") setup_db = classmethod(setup_db) class Test_jToolkit_ADO(MySqlADOTester): PyADO = jToolkit_PyADO disabled = (jToolkit_PyADO is None) def setup_db(cls): return cls.PyADO.connect(None, user="mytest", password="", database="mytest", provider="MySQLProv") setup_db = classmethod(setup_db) |