def test_non_dict_added_to_unprocessed_items_after_5_failures(self): base = BaseDispatcher('test_subject', 'send_lots', 'send_one', max_batch_size=3) client_error = ClientError( {"Error": { "message": "Something went wrong", "code": 0 }}, "A Test") base._individual_dispatch_method = Mock(side_effect=[ client_error, client_error, client_error, client_error, client_error ]) test_payload = "abc" base._send_individual_payload(test_payload) base._individual_dispatch_method.assert_has_calls([ call(test_payload), call(test_payload), call(test_payload), call(test_payload), call(test_payload) ]) self.assertEqual([test_payload], base.unprocessed_items)
def test_successful_send_non_dict(self): base = BaseDispatcher('test_subject', 'send_lots', 'send_one', max_batch_size=3) base._individual_dispatch_method = Mock() test_payload = "abc" base._send_individual_payload(test_payload) base._individual_dispatch_method.assert_called_once_with(test_payload)
def test_successfully_sent_after_4_failures_dict(self): base = BaseDispatcher('test_subject', 'send_lots', 'send_one', max_batch_size=3) client_error = ClientError( {"Error": { "message": "Something went wrong", "code": 0 }}, "A Test") base._individual_dispatch_method = Mock(side_effect=[ client_error, client_error, client_error, client_error, "" ]) test_payload = {"abc": 123} base._send_individual_payload(test_payload) base._individual_dispatch_method.assert_has_calls([ call(**test_payload), call(**test_payload), call(**test_payload), call(**test_payload), call(**test_payload) ])