@@ -78,7 +78,7 @@ def test_ionq_client_attributes():
7878 max_retry_seconds = 10 ,
7979 verbose = True ,
8080 )
81- assert client .url == 'http://example.com/v0.1 '
81+ assert client .url == 'http://example.com/v0.3 '
8282 assert client .headers == {
8383 'Authorization' : 'apiKey to_my_heart' ,
8484 'Content-Type' : 'application/json' ,
@@ -96,7 +96,9 @@ def test_ionq_client_create_job(mock_post):
9696 mock_post .return_value .json .return_value = {'foo' : 'bar' }
9797
9898 client = ionq .ionq_client ._IonQClient (remote_host = 'http://example.com' , api_key = 'to_my_heart' )
99- program = ionq .SerializedProgram (body = {'job' : 'mine' }, metadata = {'a' : '0,1' })
99+ program = ionq .SerializedProgram (
100+ body = {'job' : 'mine' }, metadata = {'a' : '0,1' }, error_mitigation = {'debias' : True }
101+ )
100102 response = client .create_job (
101103 serialized_program = program , repetitions = 200 , target = 'qpu' , name = 'bacon'
102104 )
@@ -108,6 +110,7 @@ def test_ionq_client_create_job(mock_post):
108110 'body' : {'job' : 'mine' },
109111 'name' : 'bacon' ,
110112 'shots' : '200' ,
113+ 'error_mitigation' : {'debias' : True },
111114 'metadata' : {'shots' : '200' , 'a' : '0,1' },
112115 }
113116 expected_headers = {
@@ -116,7 +119,42 @@ def test_ionq_client_create_job(mock_post):
116119 'User-Agent' : client ._user_agent (),
117120 }
118121 mock_post .assert_called_with (
119- 'http://example.com/v0.1/jobs' , json = expected_json , headers = expected_headers
122+ 'http://example.com/v0.3/jobs' , json = expected_json , headers = expected_headers
123+ )
124+
125+
126+ @mock .patch ('requests.post' )
127+ def test_ionq_client_create_job_extra_params (mock_post ):
128+ mock_post .return_value .status_code .return_value = requests .codes .ok
129+ mock_post .return_value .json .return_value = {'foo' : 'bar' }
130+
131+ client = ionq .ionq_client ._IonQClient (remote_host = 'http://example.com' , api_key = 'to_my_heart' )
132+ program = ionq .SerializedProgram (body = {'job' : 'mine' }, metadata = {'a' : '0,1' })
133+ response = client .create_job (
134+ serialized_program = program ,
135+ repetitions = 200 ,
136+ target = 'qpu' ,
137+ name = 'bacon' ,
138+ extra_query_params = {'error_mitigation' : {'debias' : True }},
139+ )
140+ assert response == {'foo' : 'bar' }
141+
142+ expected_json = {
143+ 'target' : 'qpu' ,
144+ 'lang' : 'json' ,
145+ 'body' : {'job' : 'mine' },
146+ 'name' : 'bacon' ,
147+ 'shots' : '200' ,
148+ 'error_mitigation' : {'debias' : True },
149+ 'metadata' : {'shots' : '200' , 'a' : '0,1' },
150+ }
151+ expected_headers = {
152+ 'Authorization' : 'apiKey to_my_heart' ,
153+ 'Content-Type' : 'application/json' ,
154+ 'User-Agent' : client ._user_agent (),
155+ }
156+ mock_post .assert_called_with (
157+ 'http://example.com/v0.3/jobs' , json = expected_json , headers = expected_headers
120158 )
121159
122160
@@ -272,7 +310,7 @@ def test_ionq_client_get_job_retry_409(mock_get):
272310 'Content-Type' : 'application/json' ,
273311 'User-Agent' : client ._user_agent (),
274312 }
275- mock_get .assert_called_with ('http://example.com/v0.1 /jobs/job_id' , headers = expected_headers )
313+ mock_get .assert_called_with ('http://example.com/v0.3 /jobs/job_id' , headers = expected_headers )
276314
277315
278316@mock .patch ('requests.get' )
@@ -288,7 +326,7 @@ def test_ionq_client_get_job(mock_get):
288326 'Content-Type' : 'application/json' ,
289327 'User-Agent' : client ._user_agent (),
290328 }
291- mock_get .assert_called_with ('http://example.com/v0.1 /jobs/job_id' , headers = expected_headers )
329+ mock_get .assert_called_with ('http://example.com/v0.3 /jobs/job_id' , headers = expected_headers )
292330
293331
294332@mock .patch ('requests.get' )
@@ -342,6 +380,46 @@ def test_ionq_client_get_job_retry(mock_get):
342380 assert mock_get .call_count == 2
343381
344382
383+ @mock .patch ('requests.get' )
384+ def test_ionq_client_get_results (mock_get ):
385+ mock_get .return_value .ok = True
386+ mock_get .return_value .json .return_value = {'foo' : 'bar' }
387+ client = ionq .ionq_client ._IonQClient (remote_host = 'http://example.com' , api_key = 'to_my_heart' )
388+ response = client .get_results (job_id = 'job_id' , sharpen = False )
389+ assert response == {'foo' : 'bar' }
390+
391+ expected_headers = {
392+ 'Authorization' : 'apiKey to_my_heart' ,
393+ 'Content-Type' : 'application/json' ,
394+ 'User-Agent' : client ._user_agent (),
395+ }
396+ mock_get .assert_called_with (
397+ 'http://example.com/v0.3/jobs/job_id/results' ,
398+ headers = expected_headers ,
399+ params = {'sharpen' : False },
400+ )
401+
402+
403+ @mock .patch ('requests.get' )
404+ def test_ionq_client_get_results_extra_params (mock_get ):
405+ mock_get .return_value .ok = True
406+ mock_get .return_value .json .return_value = {'foo' : 'bar' }
407+ client = ionq .ionq_client ._IonQClient (remote_host = 'http://example.com' , api_key = 'to_my_heart' )
408+ response = client .get_results (job_id = 'job_id' , extra_query_params = {'sharpen' : False })
409+ assert response == {'foo' : 'bar' }
410+
411+ expected_headers = {
412+ 'Authorization' : 'apiKey to_my_heart' ,
413+ 'Content-Type' : 'application/json' ,
414+ 'User-Agent' : client ._user_agent (),
415+ }
416+ mock_get .assert_called_with (
417+ 'http://example.com/v0.3/jobs/job_id/results' ,
418+ headers = expected_headers ,
419+ params = {'sharpen' : False },
420+ )
421+
422+
345423@mock .patch ('requests.get' )
346424def test_ionq_client_list_jobs (mock_get ):
347425 mock_get .return_value .ok = True
@@ -356,7 +434,7 @@ def test_ionq_client_list_jobs(mock_get):
356434 'User-Agent' : client ._user_agent (),
357435 }
358436 mock_get .assert_called_with (
359- 'http://example.com/v0.1 /jobs' , headers = expected_headers , json = {'limit' : 1000 }, params = {}
437+ 'http://example.com/v0.3 /jobs' , headers = expected_headers , json = {'limit' : 1000 }, params = {}
360438 )
361439
362440
@@ -374,7 +452,7 @@ def test_ionq_client_list_jobs_status(mock_get):
374452 'User-Agent' : client ._user_agent (),
375453 }
376454 mock_get .assert_called_with (
377- 'http://example.com/v0.1 /jobs' ,
455+ 'http://example.com/v0.3 /jobs' ,
378456 headers = expected_headers ,
379457 json = {'limit' : 1000 },
380458 params = {'status' : 'canceled' },
@@ -395,7 +473,7 @@ def test_ionq_client_list_jobs_limit(mock_get):
395473 'User-Agent' : client ._user_agent (),
396474 }
397475 mock_get .assert_called_with (
398- 'http://example.com/v0.1 /jobs' , headers = expected_headers , json = {'limit' : 1000 }, params = {}
476+ 'http://example.com/v0.3 /jobs' , headers = expected_headers , json = {'limit' : 1000 }, params = {}
399477 )
400478
401479
@@ -416,7 +494,7 @@ def test_ionq_client_list_jobs_batches(mock_get):
416494 'Content-Type' : 'application/json' ,
417495 'User-Agent' : client ._user_agent (),
418496 }
419- url = 'http://example.com/v0.1 /jobs'
497+ url = 'http://example.com/v0.3 /jobs'
420498 mock_get .assert_has_calls (
421499 [
422500 mock .call (url , headers = expected_headers , json = {'limit' : 1 }, params = {}),
@@ -445,7 +523,7 @@ def test_ionq_client_list_jobs_batches_does_not_divide_total(mock_get):
445523 'Content-Type' : 'application/json' ,
446524 'User-Agent' : client ._user_agent (),
447525 }
448- url = 'http://example.com/v0.1 /jobs'
526+ url = 'http://example.com/v0.3 /jobs'
449527 mock_get .assert_has_calls (
450528 [
451529 mock .call (url , headers = expected_headers , json = {'limit' : 2 }, params = {}),
@@ -503,7 +581,7 @@ def test_ionq_client_cancel_job(mock_put):
503581 'User-Agent' : client ._user_agent (),
504582 }
505583 mock_put .assert_called_with (
506- 'http://example.com/v0.1 /jobs/job_id/status/cancel' , headers = expected_headers
584+ 'http://example.com/v0.3 /jobs/job_id/status/cancel' , headers = expected_headers
507585 )
508586
509587
@@ -571,7 +649,7 @@ def test_ionq_client_delete_job(mock_delete):
571649 'Content-Type' : 'application/json' ,
572650 'User-Agent' : client ._user_agent (),
573651 }
574- mock_delete .assert_called_with ('http://example.com/v0.1 /jobs/job_id' , headers = expected_headers )
652+ mock_delete .assert_called_with ('http://example.com/v0.3 /jobs/job_id' , headers = expected_headers )
575653
576654
577655@mock .patch ('requests.delete' )
@@ -639,7 +717,7 @@ def test_ionq_client_get_current_calibrations(mock_get):
639717 'User-Agent' : client ._user_agent (),
640718 }
641719 mock_get .assert_called_with (
642- 'http://example.com/v0.1 /calibrations/current' , headers = expected_headers
720+ 'http://example.com/v0.3 /calibrations/current' , headers = expected_headers
643721 )
644722
645723
@@ -700,7 +778,7 @@ def test_ionq_client_list_calibrations(mock_get):
700778 'User-Agent' : client ._user_agent (),
701779 }
702780 mock_get .assert_called_with (
703- 'http://example.com/v0.1 /calibrations' ,
781+ 'http://example.com/v0.3 /calibrations' ,
704782 headers = expected_headers ,
705783 json = {'limit' : 1000 },
706784 params = {},
@@ -724,7 +802,7 @@ def test_ionq_client_list_calibrations_dates(mock_get):
724802 'User-Agent' : client ._user_agent (),
725803 }
726804 mock_get .assert_called_with (
727- 'http://example.com/v0.1 /calibrations' ,
805+ 'http://example.com/v0.3 /calibrations' ,
728806 headers = expected_headers ,
729807 json = {'limit' : 1000 },
730808 params = {'start' : 1284286794000 , 'end' : 1284286795000 },
@@ -747,7 +825,7 @@ def test_ionq_client_list_calibrations_limit(mock_get):
747825 'User-Agent' : client ._user_agent (),
748826 }
749827 mock_get .assert_called_with (
750- 'http://example.com/v0.1 /calibrations' ,
828+ 'http://example.com/v0.3 /calibrations' ,
751829 headers = expected_headers ,
752830 json = {'limit' : 1000 },
753831 params = {},
@@ -771,7 +849,7 @@ def test_ionq_client_list_calibrations_batches(mock_get):
771849 'Content-Type' : 'application/json' ,
772850 'User-Agent' : client ._user_agent (),
773851 }
774- url = 'http://example.com/v0.1 /calibrations'
852+ url = 'http://example.com/v0.3 /calibrations'
775853 mock_get .assert_has_calls (
776854 [
777855 mock .call (url , headers = expected_headers , json = {'limit' : 1 }, params = {}),
@@ -800,7 +878,7 @@ def test_ionq_client_list_calibrations_batches_does_not_divide_total(mock_get):
800878 'Content-Type' : 'application/json' ,
801879 'User-Agent' : client ._user_agent (),
802880 }
803- url = 'http://example.com/v0.1 /calibrations'
881+ url = 'http://example.com/v0.3 /calibrations'
804882 mock_get .assert_has_calls (
805883 [
806884 mock .call (url , headers = expected_headers , json = {'limit' : 2 }, params = {}),
0 commit comments