def test_list_batch_send_failures_sent_to_unprocessed_items(self): base = BaseDispatcher('test_subject', 'send_lots', 'send_one', max_batch_size=3) test_batch = ["abc", "cde"] base._batch_dispatch_method = Mock(side_effect=ClientError( {"Error": { "message": "Something went wrong", "code": 0 }}, "A Test")) base._process_batch_send_response = Mock() base._handle_client_error = Mock() base._unpack_failed_batch_to_unprocessed_items = Mock() base._batch_send_payloads(test_batch) base._batch_dispatch_method.assert_has_calls([ call(test_batch), call(test_batch), call(test_batch), call(test_batch), call(test_batch) ]) base._process_batch_send_response.assert_not_called() base._unpack_failed_batch_to_unprocessed_items.assert_called_once_with( test_batch)
def test_dict(self): base = BaseDispatcher('test_subject', 'send_lots', 'send_one', max_batch_size=3) test_batch = {'something_to_process': [1, 2, 3, 4, 5, 6]} base._batch_dispatch_method = Mock(return_value="batch_response") base._process_batch_send_response = Mock() base._batch_send_payloads(test_batch) base._batch_dispatch_method.assert_called_once_with(**test_batch) base._process_batch_send_response.assert_called_once_with( "batch_response")
def test_empty_list(self): base = BaseDispatcher('test_subject', 'send_lots', 'send_one', max_batch_size=3) test_batch = [] base._batch_dispatch_method = Mock(return_value="batch_response") base._process_batch_send_response = Mock() base._batch_send_payloads(test_batch) base._batch_dispatch_method.assert_called_once_with(test_batch) base._process_batch_send_response.assert_called_once_with( "batch_response")