From: David F. <dav...@us...> - 2006-06-28 10:26:54
|
Update of /cvsroot/myoledb/myoledb3/test In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv1319 Modified Files: test_dbapi.py Log Message: added support for adodbapi (adodbapi.sf.net) this returns results in tuples, not lists, so handle accordingly make common connection params set driver as attribute more regularly Index: test_dbapi.py =================================================================== RCS file: /cvsroot/myoledb/myoledb3/test/test_dbapi.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_dbapi.py 28 Jun 2006 10:06:32 -0000 1.1 +++ test_dbapi.py 28 Jun 2006 10:26:50 -0000 1.2 @@ -13,7 +13,17 @@ except ImportError: j5_PyADO = None +try: + import adodbapi +except ImportError: + adodbapi = None + class MySqlADOTester: + class connection: + username = "mytest" + password = "" + database = "mytest" + provider = "MySQLProv" def setup_class(cls): cls.db = cls.setup_db() def teardown_class(cls): @@ -30,7 +40,8 @@ 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"]] + assert len(results) == 1 + assert list(results[0]) == ["test", "me"] def test_count_type(self): try: self.execute_query("drop table test_count_type") @@ -39,19 +50,29 @@ 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]] + assert len(results) == 1 + assert list(results[0]) == [1] class Test_j5_ADO(MySqlADOTester): - PyADO = j5_PyADO + driver = j5_PyADO disabled = (j5_PyADO is None) def setup_db(cls): - return cls.PyADO.connect(None, {"User ID": "mytest", "Password": "", "Data Source": "mytest"}, "MySQLProv") + return cls.driver.connect(None, {"User ID": cls.connection.username, "Password": cls.connection.password, "Data Source": cls.connection.database}, cls.connection.provider) setup_db = classmethod(setup_db) class Test_jToolkit_ADO(MySqlADOTester): - PyADO = jToolkit_PyADO + driver = jToolkit_PyADO disabled = (jToolkit_PyADO is None) def setup_db(cls): - return cls.PyADO.connect(None, user="mytest", password="", database="mytest", provider="MySQLProv") + return cls.driver.connect(None, user=cls.connection.username, password=cls.connection.password, database=cls.connection.database, provider=cls.connection.provider) + setup_db = classmethod(setup_db) + +class Test_adodbapi(MySqlADOTester): + driver = adodbapi + disabled = (adodbapi is None) + def setup_db(cls): + params = {"User ID": cls.connection.username, "Password": cls.connection.password, "Data Source": cls.connection.database, "Provider": cls.connection.provider} + paramstr = "; ".join(["%s=%s" % (key, value) for key, value in params.iteritems()]) + return cls.driver.connect(paramstr) setup_db = classmethod(setup_db) |