@@ -78,7 +78,7 @@ def test_ionq_client_attributes():
78
78
max_retry_seconds = 10 ,
79
79
verbose = True ,
80
80
)
81
- assert client .url == 'http://example.com/v0.1 '
81
+ assert client .url == 'http://example.com/v0.3 '
82
82
assert client .headers == {
83
83
'Authorization' : 'apiKey to_my_heart' ,
84
84
'Content-Type' : 'application/json' ,
@@ -96,7 +96,9 @@ def test_ionq_client_create_job(mock_post):
96
96
mock_post .return_value .json .return_value = {'foo' : 'bar' }
97
97
98
98
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
+ )
100
102
response = client .create_job (
101
103
serialized_program = program , repetitions = 200 , target = 'qpu' , name = 'bacon'
102
104
)
@@ -108,6 +110,7 @@ def test_ionq_client_create_job(mock_post):
108
110
'body' : {'job' : 'mine' },
109
111
'name' : 'bacon' ,
110
112
'shots' : '200' ,
113
+ 'error_mitigation' : {'debias' : True },
111
114
'metadata' : {'shots' : '200' , 'a' : '0,1' },
112
115
}
113
116
expected_headers = {
@@ -116,7 +119,42 @@ def test_ionq_client_create_job(mock_post):
116
119
'User-Agent' : client ._user_agent (),
117
120
}
118
121
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
120
158
)
121
159
122
160
@@ -272,7 +310,7 @@ def test_ionq_client_get_job_retry_409(mock_get):
272
310
'Content-Type' : 'application/json' ,
273
311
'User-Agent' : client ._user_agent (),
274
312
}
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 )
276
314
277
315
278
316
@mock .patch ('requests.get' )
@@ -288,7 +326,7 @@ def test_ionq_client_get_job(mock_get):
288
326
'Content-Type' : 'application/json' ,
289
327
'User-Agent' : client ._user_agent (),
290
328
}
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 )
292
330
293
331
294
332
@mock .patch ('requests.get' )
@@ -342,6 +380,46 @@ def test_ionq_client_get_job_retry(mock_get):
342
380
assert mock_get .call_count == 2
343
381
344
382
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
+
345
423
@mock .patch ('requests.get' )
346
424
def test_ionq_client_list_jobs (mock_get ):
347
425
mock_get .return_value .ok = True
@@ -356,7 +434,7 @@ def test_ionq_client_list_jobs(mock_get):
356
434
'User-Agent' : client ._user_agent (),
357
435
}
358
436
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 = {}
360
438
)
361
439
362
440
@@ -374,7 +452,7 @@ def test_ionq_client_list_jobs_status(mock_get):
374
452
'User-Agent' : client ._user_agent (),
375
453
}
376
454
mock_get .assert_called_with (
377
- 'http://example.com/v0.1 /jobs' ,
455
+ 'http://example.com/v0.3 /jobs' ,
378
456
headers = expected_headers ,
379
457
json = {'limit' : 1000 },
380
458
params = {'status' : 'canceled' },
@@ -395,7 +473,7 @@ def test_ionq_client_list_jobs_limit(mock_get):
395
473
'User-Agent' : client ._user_agent (),
396
474
}
397
475
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 = {}
399
477
)
400
478
401
479
@@ -416,7 +494,7 @@ def test_ionq_client_list_jobs_batches(mock_get):
416
494
'Content-Type' : 'application/json' ,
417
495
'User-Agent' : client ._user_agent (),
418
496
}
419
- url = 'http://example.com/v0.1 /jobs'
497
+ url = 'http://example.com/v0.3 /jobs'
420
498
mock_get .assert_has_calls (
421
499
[
422
500
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):
445
523
'Content-Type' : 'application/json' ,
446
524
'User-Agent' : client ._user_agent (),
447
525
}
448
- url = 'http://example.com/v0.1 /jobs'
526
+ url = 'http://example.com/v0.3 /jobs'
449
527
mock_get .assert_has_calls (
450
528
[
451
529
mock .call (url , headers = expected_headers , json = {'limit' : 2 }, params = {}),
@@ -503,7 +581,7 @@ def test_ionq_client_cancel_job(mock_put):
503
581
'User-Agent' : client ._user_agent (),
504
582
}
505
583
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
507
585
)
508
586
509
587
@@ -571,7 +649,7 @@ def test_ionq_client_delete_job(mock_delete):
571
649
'Content-Type' : 'application/json' ,
572
650
'User-Agent' : client ._user_agent (),
573
651
}
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 )
575
653
576
654
577
655
@mock .patch ('requests.delete' )
@@ -639,7 +717,7 @@ def test_ionq_client_get_current_calibrations(mock_get):
639
717
'User-Agent' : client ._user_agent (),
640
718
}
641
719
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
643
721
)
644
722
645
723
@@ -700,7 +778,7 @@ def test_ionq_client_list_calibrations(mock_get):
700
778
'User-Agent' : client ._user_agent (),
701
779
}
702
780
mock_get .assert_called_with (
703
- 'http://example.com/v0.1 /calibrations' ,
781
+ 'http://example.com/v0.3 /calibrations' ,
704
782
headers = expected_headers ,
705
783
json = {'limit' : 1000 },
706
784
params = {},
@@ -724,7 +802,7 @@ def test_ionq_client_list_calibrations_dates(mock_get):
724
802
'User-Agent' : client ._user_agent (),
725
803
}
726
804
mock_get .assert_called_with (
727
- 'http://example.com/v0.1 /calibrations' ,
805
+ 'http://example.com/v0.3 /calibrations' ,
728
806
headers = expected_headers ,
729
807
json = {'limit' : 1000 },
730
808
params = {'start' : 1284286794000 , 'end' : 1284286795000 },
@@ -747,7 +825,7 @@ def test_ionq_client_list_calibrations_limit(mock_get):
747
825
'User-Agent' : client ._user_agent (),
748
826
}
749
827
mock_get .assert_called_with (
750
- 'http://example.com/v0.1 /calibrations' ,
828
+ 'http://example.com/v0.3 /calibrations' ,
751
829
headers = expected_headers ,
752
830
json = {'limit' : 1000 },
753
831
params = {},
@@ -771,7 +849,7 @@ def test_ionq_client_list_calibrations_batches(mock_get):
771
849
'Content-Type' : 'application/json' ,
772
850
'User-Agent' : client ._user_agent (),
773
851
}
774
- url = 'http://example.com/v0.1 /calibrations'
852
+ url = 'http://example.com/v0.3 /calibrations'
775
853
mock_get .assert_has_calls (
776
854
[
777
855
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):
800
878
'Content-Type' : 'application/json' ,
801
879
'User-Agent' : client ._user_agent (),
802
880
}
803
- url = 'http://example.com/v0.1 /calibrations'
881
+ url = 'http://example.com/v0.3 /calibrations'
804
882
mock_get .assert_has_calls (
805
883
[
806
884
mock .call (url , headers = expected_headers , json = {'limit' : 2 }, params = {}),
0 commit comments