1818
1919import pytest
2020import requests
21- from requests .compat import urljoin
2221
2322from projectq .backends ._exceptions import JobSubmissionError , RequestTimeoutError
2423from projectq .backends ._ionq import _ionq_http_client
@@ -30,9 +29,6 @@ def no_requests(monkeypatch):
3029 monkeypatch .delattr ('requests.sessions.Session.request' )
3130
3231
33- _api_url = 'https://api.ionq.co/v0.1/jobs/'
34-
35-
3632def test_authenticate ():
3733 ionq_session = _ionq_http_client .IonQ ()
3834 ionq_session .authenticate ('NotNone' )
@@ -55,7 +51,7 @@ def user_password_input(prompt):
5551
5652def test_is_online (monkeypatch ):
5753 def mock_get (_self , path , * args , ** kwargs ):
58- assert urljoin ( _api_url , ' backends') == path
54+ assert 'https://api.ionq.co/v0.2/ backends' == path
5955 mock_response = mock .MagicMock ()
6056 mock_response .json = mock .MagicMock (
6157 return_value = [
@@ -91,7 +87,7 @@ def mock_get(_self, path, *args, **kwargs):
9187
9288def test_show_devices (monkeypatch ):
9389 def mock_get (_self , path , * args , ** kwargs ):
94- assert urljoin ( _api_url , ' backends') == path
90+ assert 'https://api.ionq.co/v0.2/ backends' == path
9591 mock_response = mock .MagicMock ()
9692 mock_response .json = mock .MagicMock (
9793 return_value = [
@@ -187,7 +183,7 @@ def _dummy_update(_self):
187183 }
188184
189185 def mock_post (_self , path , * args , ** kwargs ):
190- assert path == _api_url [: - 1 ]
186+ assert path == 'https://api.ionq.co/v0.2/jobs'
191187 assert 'json' in kwargs
192188 assert expected_request == kwargs ['json' ]
193189 mock_response = mock .MagicMock ()
@@ -201,7 +197,7 @@ def mock_post(_self, path, *args, **kwargs):
201197 return mock_response
202198
203199 def mock_get (_self , path , * args , ** kwargs ):
204- assert urljoin ( _api_url , ' new-job-id') == path
200+ assert path == 'https://api.ionq.co/v0.2/jobs/ new-job-id'
205201 mock_response = mock .MagicMock ()
206202 mock_response .json = mock .MagicMock (
207203 return_value = {
@@ -433,7 +429,7 @@ def _dummy_update(_self):
433429 )
434430
435431 def mock_post (_self , path , ** kwargs ):
436- assert _api_url [: - 1 ] == path
432+ assert path == 'https://api.ionq.co/v0.2/jobs'
437433 mock_response = mock .MagicMock ()
438434 mock_response .json = mock .MagicMock (return_value = err_data )
439435 return mock_response
@@ -472,7 +468,7 @@ def _dummy_update(_self):
472468 )
473469
474470 def mock_post (_self , path , * args , ** kwargs ):
475- assert path == _api_url [: - 1 ]
471+ assert path == 'https://api.ionq.co/v0.2/jobs'
476472 mock_response = mock .MagicMock ()
477473 mock_response .json = mock .MagicMock (
478474 return_value = {
@@ -483,7 +479,7 @@ def mock_post(_self, path, *args, **kwargs):
483479 return mock_response
484480
485481 def mock_get (_self , path , * args , ** kwargs ):
486- assert urljoin ( _api_url , ' new-job-id') == path
482+ assert path == 'https://api.ionq.co/v0.2/jobs/ new-job-id'
487483 mock_response = mock .MagicMock ()
488484 mock_response .json = mock .MagicMock (
489485 return_value = {
@@ -533,7 +529,7 @@ def _dummy_update(_self):
533529 request_num = [0 ]
534530
535531 def mock_get (_self , path , * args , ** kwargs ):
536- assert urljoin ( _api_url , ' old-job-id') == path
532+ assert path == 'https://api.ionq.co/v0.2/jobs/ old-job-id'
537533 json_response = {
538534 'id' : 'old-job-id' ,
539535 'status' : 'running' ,
@@ -591,7 +587,7 @@ def _dummy_update(_self):
591587 request_num = [0 ]
592588
593589 def mock_get (_self , path , * args , ** kwargs ):
594- assert urljoin ( _api_url , ' old-job-id') == path
590+ assert path == 'https://api.ionq.co/v0.2/jobs/ old-job-id'
595591 json_response = {
596592 'id' : 'old-job-id' ,
597593 'status' : 'running' ,
0 commit comments