@@ -365,6 +365,84 @@ def test_batch_request_with_unhealthy_service(
365
365
),
366
366
}
367
367
368
+ def test_batch_request_with_unhealthy_service_and_none_error_data (
369
+ self ,
370
+ spy_plugin_controller ,
371
+ test_data ,
372
+ batch_request ,
373
+ mock_hypernova_query ,
374
+ ):
375
+ data = test_data [0 ]
376
+ job = Job (name = 'MyComponent.js' , data = data [0 ], context = {})
377
+ token = batch_request .render ('MyComponent.js' , data [0 ])
378
+
379
+ mock_hypernova_query .return_value .json .side_effect = HypernovaQueryError (
380
+ 'oh no' ,
381
+ None ,
382
+ )
383
+ response = batch_request .submit ()
384
+
385
+ if batch_request .max_batch_size is None :
386
+ assert mock_hypernova_query .call_count == 1
387
+ else :
388
+ # Division (rounded-up) up to get total number of calls
389
+ jobs_count = len (batch_request .jobs )
390
+ max_batch_size = batch_request .max_batch_size
391
+ batch_count = (jobs_count + (max_batch_size - 1 )) // max_batch_size
392
+ assert mock_hypernova_query .call_count == batch_count
393
+ mock_hypernova_query .assert_called_with (mock .ANY , mock .ANY , mock .ANY , batch_count == 1 , {})
394
+
395
+ assert response == {
396
+ token .identifier : JobResult (
397
+ error = HypernovaError (
398
+ name = 'HypernovaQueryError' ,
399
+ message = 'oh no' ,
400
+ stack = mock .ANY ,
401
+ ),
402
+ html = render_blank_markup (token .identifier , job , True , batch_request .json_encoder ),
403
+ job = job ,
404
+ ),
405
+ }
406
+
407
+ def test_batch_request_with_unhealthy_service_and_other_type_error_data (
408
+ self ,
409
+ spy_plugin_controller ,
410
+ test_data ,
411
+ batch_request ,
412
+ mock_hypernova_query ,
413
+ ):
414
+ data = test_data [0 ]
415
+ job = Job (name = 'MyComponent.js' , data = data [0 ], context = {})
416
+ token = batch_request .render ('MyComponent.js' , data [0 ])
417
+
418
+ mock_hypernova_query .return_value .json .side_effect = HypernovaQueryError (
419
+ 'oh no' ,
420
+ 'i should not be a string' ,
421
+ )
422
+ response = batch_request .submit ()
423
+
424
+ if batch_request .max_batch_size is None :
425
+ assert mock_hypernova_query .call_count == 1
426
+ else :
427
+ # Division (rounded-up) up to get total number of calls
428
+ jobs_count = len (batch_request .jobs )
429
+ max_batch_size = batch_request .max_batch_size
430
+ batch_count = (jobs_count + (max_batch_size - 1 )) // max_batch_size
431
+ assert mock_hypernova_query .call_count == batch_count
432
+ mock_hypernova_query .assert_called_with (mock .ANY , mock .ANY , mock .ANY , batch_count == 1 , {})
433
+
434
+ assert response == {
435
+ token .identifier : JobResult (
436
+ error = HypernovaError (
437
+ name = 'HypernovaQueryError' ,
438
+ message = 'oh no' ,
439
+ stack = mock .ANY ,
440
+ ),
441
+ html = render_blank_markup (token .identifier , job , True , batch_request .json_encoder ),
442
+ job = job ,
443
+ ),
444
+ }
445
+
368
446
369
447
class TestBatchRequestLifecycleMethods :
370
448
"""Test that BatchRequest calls plugin lifecycle methods at the
0 commit comments