示例#1
0
    def setUp(self):

        # Add the test table to the database, so we can use it in the tests
        with connect(user=labman_settings.user,
                     password=labman_settings.password,
                     host=labman_settings.host,
                     port=labman_settings.port,
                     database=labman_settings.database) as self.con:
            with self.con.cursor() as cur:
                cur.execute(DB_CREATE_TEST_TABLE)
        self.con.commit()
        self._files_to_remove = []
        self.conn_handler = SQLConnectionHandler()
示例#2
0
    def test_init(self):
        obs = SQLConnectionHandler()
        self.assertEqual(obs.admin, 'no_admin')
        self.assertEqual(obs.queues, {})
        self.assertTrue(isinstance(obs._connection, connection))
        self.assertEqual(self.conn_handler._user_conn.closed, 0)

        # Let's close the connection and make sure that it gets reopened
        obs.close()
        obs = SQLConnectionHandler()
        self.assertEqual(self.conn_handler._user_conn.closed, 0)
示例#3
0
 def test_init_admin_with_database(self):
     obs = SQLConnectionHandler(admin='admin_with_database')
     self.assertEqual(obs.admin, 'admin_with_database')
     self.assertEqual(obs.queues, {})
     self.assertTrue(isinstance(obs._connection, connection))
     self.assertEqual(self.conn_handler._user_conn.closed, 0)
示例#4
0
 def test_init_admin_error(self):
     with self.assertRaises(ValueError):
         SQLConnectionHandler(admin='not a valid value')