def test_invalid_proxy_port_ibmqclient(self, qe_token, qe_url): """Should raise RequestApiError with ProxyError as original exception using IBMQClient.""" with self.assertRaises(RequestsApiError) as context_manager: _ = IBMQClient(qe_token, qe_url, proxies=INVALID_PORT_PROXIES) self.assertIsInstance(context_manager.exception.original_exception, ProxyError)
def test_proxies_ibmqclient(self, qe_token, qe_url): """Should reach the proxy using IBMQClient.""" pproxy_desired_access_log_line_ = pproxy_desired_access_log_line( qe_url) _ = IBMQClient(qe_token, qe_url, proxies=VALID_PROXIES) self.proxy_process.terminate() # kill to be able of reading the output self.assertIn(pproxy_desired_access_log_line_, self.proxy_process.stdout.read().decode('utf-8'))
def _get_client(qe_token, qe_url): """Helper for instantiating an IBMQClient.""" if not ('quantum-computing.ibm.com/api' in qe_url and 'auth' in qe_url): raise SkipTest('Test needs credentials for new API') return IBMQClient(qe_token, qe_url)
def test_url_unreachable(self, qe_token, qe_url): """Test login against an invalid (malformed) URL.""" qe_url = 'INVALID_URL' with self.assertRaises(ApiError): _ = IBMQClient(qe_token, qe_url)
def test_invalid_token(self, qe_token, qe_url): """Test login using invalid token.""" qe_token = 'INVALID_TOKEN' with self.assertRaises(ApiError): _ = IBMQClient(qe_token, qe_url)
def test_url_404(self, qe_token, qe_url): """Test login against a 404 URL""" url_404 = re.sub(r'/api.*$', '/api/TEST_404', qe_url) with self.assertRaises(ApiError): _ = IBMQClient(qe_token, url_404)
def _get_client(qe_token, qe_url): """Helper for instantiating an IBMQClient.""" return IBMQClient(qe_token, qe_url)
def _get_client(qe_token, qe_url): """Helper for instantiating an IBMQClient.""" if not ('quantum-computing.ibm.com/api' in qe_url and 'auth' in qe_url): raise SkipTest('New api URL not provided') return IBMQClient(qe_token, qe_url)