""" Module : test_dburi.py License : BSD License (see LICENSE.txt) This module includes the test cases for the dburi.py module It's highly unlikely that they will all pass in one invocation as I don't have a machine with all of the different db-api modules installed. Although that may all change if I can stop wrecking my Ubuntu install. """ __version__ = (0, 1, 0) __date__ = (2006, 3, 8) __author__ = "Andy Todd " import unittest import os import dburi # Make sure we're logging at the lowest level from utilities.Log import get_log log = get_log(level='DEBUG') class TestMySqlConnection(unittest.TestCase): """ Unit tests for our MySQL connection class """ def test_init(self): "Test successful creation of a connection directly using the MySqlConnection class" mysql = dburi.MySqlConnection('/andy47:w1bble@localhost/portfolio') self.conn = mysql.connection def test_empty_init(self): "Test that passing an empty connection_string to MySqlConnection fails gracefully" self.assertRaises(ValueError, dburi.MySqlConnection, '') class TestSqliteConnection(unittest.TestCase): """ Unit test for our Sqlite connection class """ pass class TestGetConnection(unittest.TestCase): """ Unit tests for module level get_connection function """ def test_mysql(self): "Test successful creation of a MySQL connection" self.conn = dburi.get_connection('mysql://andy47:w1bble@localhost/portfolio') def test_oracle(self): "Test successful creation of an Oracle connection" uri = "oracle://andy47:andy47@oraclexe" self.conn = dburi.get_connection(uri) def test_sqlite(self): "Test successful creation of a Sqlite connection" home = os.getenv('HOME') datafile = os.path.join(home, 'Work', 'Data', 'portfolio.db') uri = 'sqlite://' + datafile self.conn = dburi.get_connection(uri) if __name__ == "__main__": unittest.main()