def testConnection(self): db.reset_connection() try: # This should throw an exception because no connection has been made yet. db.get_connection() self.fail("get_connection didn't throw an exception.") except: pass db.set_database_type("postgres") self.assertNotEqual(db.connect_default(), None) self.assertNotEqual(db.get_connection(), None) try: # This should throw an exception because the database type cannot be # changed while a connection is open. db.set_database_type("postgres") self.fail("set_database_type didn't throw an exception.") except: pass db.reset_connection() try: # This should throw an exception because the connection has already # been reset. db.get_connection() self.fail("get_connection didn't throw an exception.") except: pass
def setUp(self): db.reset_connection() db.set_database_type("postgres") self.assertNotEqual(db.connect_default(), None) self.assertNotEqual(db.get_connection(), None) pass