@@ -27,7 +27,6 @@ class MockResponse(TypedDict):
27
27
body : Union [dict [str ,Any ], str , bytes , None ]
28
28
headers : dict [str , str ]
29
29
status : int
30
- stream : bool
31
30
32
31
class ExpectedResponse (TypedDict , total = False ):
33
32
body : Union [dict [str ,Any ], str , bytes , None ]
@@ -85,10 +84,10 @@ def _run_test(
85
84
mock_response : MockResponse = {
86
85
'body' : _error_reason_body ,
87
86
'headers' : _default_mock_headers ,
88
- 'status' : 444 ,
89
- 'stream' : False
87
+ 'status' : 444
90
88
},
91
- expected_response : ExpectedResponse = None
89
+ expected_response : ExpectedResponse = None ,
90
+ stream = False
92
91
) -> Union [Exception , None ]:
93
92
94
93
if expected_response is None :
@@ -122,7 +121,7 @@ def _run_test(
122
121
)
123
122
if expect_raises :
124
123
with self .assertRaisesRegex (ApiException , expected_response ['message' ]) as e_ctx :
125
- self ._make_request (method , mock_response [ ' stream' ] )
124
+ self ._make_request (method , stream )
126
125
caught_exception = e_ctx .exception
127
126
actual_status_code = caught_exception .status_code
128
127
actual_headers = caught_exception .http_response .headers
@@ -139,7 +138,7 @@ def _run_test(
139
138
actual_body = caught_exception .http_response .text
140
139
else :
141
140
try :
142
- service_response = self ._make_request (method , mock_response [ ' stream' ] )
141
+ service_response = self ._make_request (method , stream )
143
142
actual_status_code = service_response .get_status_code ()
144
143
actual_headers = service_response .get_headers ()
145
144
actual_body = service_response .get_result ()
@@ -189,8 +188,7 @@ def test_augment_error(self):
189
188
mock_response = {
190
189
'body' : self ._error_only_body ,
191
190
'headers' : self ._content_type_header ,
192
- 'status' : 444 ,
193
- 'stream' : False
191
+ 'status' : 444
194
192
},
195
193
expected_response = {
196
194
'body' : self ._error_only_body | self ._errors_error_only
@@ -202,8 +200,7 @@ def test_augment_error_with_trace(self):
202
200
mock_response = {
203
201
'body' : self ._error_only_body ,
204
202
'headers' : self ._default_mock_headers ,
205
- 'status' : 444 ,
206
- 'stream' : False
203
+ 'status' : 444
207
204
},
208
205
expected_response = {
209
206
'body' : self ._error_only_body | self ._errors_error_only | self ._trace
@@ -215,8 +212,7 @@ def test_augment_error_reason(self):
215
212
mock_response = {
216
213
'body' : self ._error_reason_body ,
217
214
'headers' : self ._content_type_header ,
218
- 'status' : 444 ,
219
- 'stream' : False
215
+ 'status' : 444
220
216
},
221
217
expected_response = {
222
218
'body' : self ._error_reason_body | self ._errors_error_reason
@@ -228,8 +224,7 @@ def test_augment_error_reason_with_trace(self):
228
224
mock_response = {
229
225
'body' : self ._error_reason_body ,
230
226
'headers' : self ._default_mock_headers ,
231
- 'status' : 444 ,
232
- 'stream' : False
227
+ 'status' : 444
233
228
},
234
229
expected_response = {
235
230
'body' : self ._error_reason_body | self ._errors_error_reason | self ._trace
@@ -241,21 +236,20 @@ def test_augment_error_reason_stream(self):
241
236
mock_response = {
242
237
'body' : self ._error_reason_body ,
243
238
'headers' : self ._default_mock_headers ,
244
- 'status' : 444 ,
245
- 'stream' : True
239
+ 'status' : 444
246
240
},
247
241
expected_response = {
248
242
'body' : self ._error_reason_body | self ._errors_error_reason | self ._trace
249
- }
243
+ },
244
+ stream = True
250
245
)
251
246
252
247
def test_augment_json_charset (self ):
253
248
self ._run_test (
254
249
mock_response = {
255
250
'body' : self ._error_reason_body ,
256
251
'headers' : self ._request_id_header | {'content-type' : 'application/json; charset=utf-8' },
257
- 'status' : 444 ,
258
- 'stream' : False
252
+ 'status' : 444
259
253
},
260
254
expected_response = {
261
255
'body' : self ._error_reason_body | self ._errors_error_reason | self ._trace
@@ -267,8 +261,7 @@ def test_augment_no_header(self):
267
261
mock_response = {
268
262
'body' : self ._error_reason_body ,
269
263
'headers' : self ._content_type_header ,
270
- 'status' : 444 ,
271
- 'stream' : False
264
+ 'status' : 444
272
265
},
273
266
expected_response = {
274
267
'body' : self ._error_reason_body | self ._errors_error_reason
@@ -280,8 +273,7 @@ def test_no_augment_success(self):
280
273
mock_response = {
281
274
'body' : {'_id' : self ._doc_id , '_rev' : '1-abc' , 'foo' : 'bar' },
282
275
'headers' : self ._default_mock_headers ,
283
- 'status' : 200 ,
284
- 'stream' : False
276
+ 'status' : 200
285
277
}
286
278
)
287
279
@@ -291,8 +283,7 @@ def test_no_augment_head(self):
291
283
mock_response = {
292
284
'body' : None ,
293
285
'headers' : self ._default_mock_headers ,
294
- 'status' : 444 ,
295
- 'stream' : False
286
+ 'status' : 444
296
287
},
297
288
expected_response = {
298
289
'body' : b'' , # no body content for HEAD
@@ -305,8 +296,7 @@ def test_no_augment_id_only(self):
305
296
mock_response = {
306
297
'body' : {},
307
298
'headers' : self ._default_mock_headers ,
308
- 'status' : 444 ,
309
- 'stream' : False
299
+ 'status' : 444
310
300
},
311
301
expected_response = {
312
302
'body' : {},
@@ -324,8 +314,7 @@ def test_no_augment_existing_trace(self):
324
314
mock_response = {
325
315
'body' : test_body ,
326
316
'headers' : self ._default_mock_headers ,
327
- 'status' : 429 ,
328
- 'stream' : False
317
+ 'status' : 429
329
318
},
330
319
expected_response = {
331
320
'body' : test_body ,
@@ -347,8 +336,7 @@ def test_no_augment_existing_errors_no_id(self):
347
336
mock_response = {
348
337
'body' : test_body ,
349
338
'headers' : self ._content_type_header ,
350
- 'status' : 403 ,
351
- 'stream' : False
339
+ 'status' : 403
352
340
},
353
341
expected_response = {
354
342
'body' : test_body ,
@@ -369,8 +357,7 @@ def test_augment_trace_existing_errors(self):
369
357
mock_response = {
370
358
'body' : test_body ,
371
359
'headers' : self ._default_mock_headers ,
372
- 'status' : 403 ,
373
- 'stream' : False
360
+ 'status' : 403
374
361
},
375
362
expected_response = {
376
363
'body' : test_body | self ._trace
@@ -383,8 +370,7 @@ def test_no_augment_non_json(self):
383
370
mock_response = {
384
371
'body' : test_body ,
385
372
'headers' : self ._request_id_header | {'content-type' : 'text/plain' },
386
- 'status' : 400 ,
387
- 'stream' : False
373
+ 'status' : 400
388
374
},
389
375
expected_response = {
390
376
'body' : test_body ,
@@ -398,8 +384,7 @@ def test_no_augment_no_content_type(self):
398
384
mock_response = {
399
385
'body' : test_body ,
400
386
'headers' : self ._request_id_header ,
401
- 'status' : 444 ,
402
- 'stream' : False
387
+ 'status' : 444
403
388
},
404
389
expected_response = {
405
390
'body' : test_body ,
@@ -413,8 +398,7 @@ def test_no_augment_no_error(self):
413
398
mock_response = {
414
399
'body' : test_body ,
415
400
'headers' : self ._default_mock_headers ,
416
- 'status' : 400 ,
417
- 'stream' : False
401
+ 'status' : 400
418
402
},
419
403
expected_response = {
420
404
'body' : test_body ,
@@ -428,8 +412,7 @@ def test_no_augment_no_error_no_header(self):
428
412
mock_response = {
429
413
'body' : test_body ,
430
414
'headers' : self ._content_type_header ,
431
- 'status' : 400 ,
432
- 'stream' : False
415
+ 'status' : 400
433
416
},
434
417
expected_response = {
435
418
'body' : test_body ,
@@ -443,8 +426,7 @@ def test_no_augment_invalid_json(self):
443
426
mock_response = {
444
427
'body' : test_body ,
445
428
'headers' : self ._content_type_header ,
446
- 'status' : 400 ,
447
- 'stream' : False
429
+ 'status' : 400
448
430
},
449
431
expected_response = {
450
432
'body' : test_body ,
@@ -460,8 +442,7 @@ def test_augment_error_empty_reason_with_trace(self):
460
442
mock_response = {
461
443
'body' : test_body ,
462
444
'headers' : self ._default_mock_headers ,
463
- 'status' : 444 ,
464
- 'stream' : False
445
+ 'status' : 444
465
446
},
466
447
expected_response = {
467
448
'body' : test_body | self ._errors_error_only | self ._trace ,
0 commit comments