def test_hbase_connection(self): conn = hbase.Connection(self.db_manager.url) self.assertIsInstance(conn.conn_pool.connection(), hbase_inmemory.MConnection) class TestConn(object): def __init__(self, host, port): self.netloc = '%s:%s' % (host, port) def open(self): pass def get_connection_pool(conf): return TestConn(conf['host'], conf['port']) with mock.patch.object(hbase.Connection, '_get_connection_pool', side_effect=get_connection_pool): conn = hbase.Connection('hbase://test_hbase:9090') self.assertIsInstance(conn.conn_pool, TestConn)
def test_hbase_connection(self): self.CONF.database.connection = str(self.database_connection) conn = hbase.Connection(self.CONF) self.assertIsInstance(conn.conn, hbase.MConnection) class TestConn(object): def __init__(self, host, port): self.netloc = '%s:%s' % (host, port) def open(self): pass def get_connection(conf): return TestConn(conf['host'], conf['port']) self.CONF.database.connection = 'hbase://test_hbase:9090' with patch.object(hbase.Connection, '_get_connection', side_effect=get_connection): conn = hbase.Connection(self.CONF) self.assertIsInstance(conn.conn, TestConn)