def sqlquery_client(): sql_client = SQLQuery('mock-api-key', 'mock-crn', client_info='ibmcloudsql test') # TODO mock method .logon() instead of hacking # disable authentication step for 300s sql_client.logged_on = True sql_client.last_logon = datetime.now() sql_client.request_headers.update( {'authorization': 'Bearer {}'.format("mock")}) return sql_client
def __init__(self, connection, configuration): auth = configuration.get('auth') client_info = configuration.get('client_info') instance_crn = connection.get('instance_crn') target_cos = connection.get('target_cos') self.api_client = SQLQuery(auth["bxapikey"], instance_crn, target_cos, client_info=client_info) self.api_client.logon() self.results_connector = CloudSQLResultsConnector(self.api_client) self.status_connector = CloudSQLStatusConnector(self.api_client) self.query_connector = CloudSQLQueryConnector(self.api_client) self.ping_connector = CloudSQLPing(self.api_client) self.delete_connector = CloudSQLDeleteConnector(self.api_client) self.is_async = True
def test_init(): sqlClient = SQLQuery('mock-api-key', 'mock-crn', client_info='ibmcloudsql test') assert (sqlClient.request_headers == { 'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': sqlClient.user_agent })
def __init__(self, connection={}, configuration={}, options={}): super().__init__(options) if connection: auth = configuration.get('auth') client_info = configuration.get('client_info') instance_crn = connection.get('instance_crn') target_cos = connection.get('target_cos') api_client = SQLQuery(auth["bxapikey"], instance_crn, target_cos, client_info=client_info) api_client.logon() ping_connector = CloudSQLPingConnector(api_client) query_connector = CloudSQLQueryConnector(api_client) status_connector = CloudSQLStatusConnector(api_client) results_connector = CloudSQLResultsConnector(api_client) delete_connector = CloudSQLDeleteConnector(api_client) self.set_ping_connector(ping_connector) self.set_query_connector(query_connector) self.set_status_connector(status_connector) self.set_results_connector(results_connector) self.set_delete_connector(delete_connector)