@@ -181,12 +181,12 @@ def test_ionq_client_create_job_not_found(mock_post):
181
181
@mock .patch ('requests.post' )
182
182
def test_ionq_client_create_job_not_retriable (mock_post ):
183
183
mock_post .return_value .ok = False
184
- mock_post .return_value .status_code = requests .codes .not_implemented
184
+ mock_post .return_value .status_code = requests .codes .conflict
185
185
186
186
client = ionq .ionq_client ._IonQClient (
187
187
remote_host = 'http://example.com' , api_key = 'to_my_heart' , default_target = 'simulator'
188
188
)
189
- with pytest .raises (ionq .IonQException , match = 'Status: 501 ' ):
189
+ with pytest .raises (ionq .IonQException , match = 'Status: 409 ' ):
190
190
_ = client .create_job (
191
191
serialized_program = ionq .SerializedProgram (body = {'job' : 'mine' }, metadata = {})
192
192
)
@@ -246,6 +246,25 @@ def test_ionq_client_create_job_timeout(mock_post):
246
246
)
247
247
248
248
249
+ @mock .patch ('requests.get' )
250
+ def test_ionq_client_get_job_retry_409 (mock_get ):
251
+ response1 = mock .MagicMock ()
252
+ response2 = mock .MagicMock ()
253
+ mock_get .side_effect = [response1 , response2 ]
254
+ response1 .ok = False
255
+ response1 .status_code = requests .codes .conflict
256
+ response1 .request .method = "GET"
257
+ response2 .ok = True
258
+ response2 .json .return_value = {'foo' : 'bar' }
259
+
260
+ client = ionq .ionq_client ._IonQClient (remote_host = 'http://example.com' , api_key = 'to_my_heart' )
261
+ response = client .get_job (job_id = 'job_id' )
262
+ assert response == {'foo' : 'bar' }
263
+
264
+ expected_headers = {'Authorization' : 'apiKey to_my_heart' , 'Content-Type' : 'application/json' }
265
+ mock_get .assert_called_with ('http://example.com/v0.1/jobs/job_id' , headers = expected_headers )
266
+
267
+
249
268
@mock .patch ('requests.get' )
250
269
def test_ionq_client_get_job (mock_get ):
251
270
mock_get .return_value .ok = True
0 commit comments