Ejemplo n.º 1
0
 def test_payload_list_equal_max_batch_size(self):
     base = BaseDispatcher('test_subject',
                           'send_lots',
                           'send_one',
                           max_batch_size=3)
     base._batch_payload = [1, 2, 3]
     base._batch_send_payloads = Mock()
     base._flush_payload_selector()
     base._batch_send_payloads.assert_called_once_with([1, 2, 3])
Ejemplo n.º 2
0
 def test_payload_list_less_than_max_batch_size(self):
     base = BaseDispatcher('test_subject',
                           'send_lots',
                           'send_one',
                           max_batch_size=3)
     base._batch_payload = [1, 2]
     base._batch_send_payloads = Mock()
     base._flush_payload_selector()
     base._batch_send_payloads.assert_not_called()
Ejemplo n.º 3
0
 def test_payload_list_greater_than_max_batch_size(self):
     base = BaseDispatcher('test_subject',
                           'send_lots',
                           'send_one',
                           max_batch_size=3)
     base._batch_payload = [1, 2, 3, 4]
     base._batch_send_payloads = Mock()
     base._flush_payload_selector()
     base._batch_send_payloads.assert_has_calls(
         [call([1, 2, 3]), call([4])])
Ejemplo n.º 4
0
 def test_when_payload_list_is_empty(self):
     base = BaseDispatcher('test_subject',
                           'send_lots',
                           'send_one',
                           max_batch_size=1)
     base._aws_service_message_max_bytes = 15
     base._aws_service_batch_max_bytes = 15
     base._append_payload_to_current_batch = Mock()
     base._flush_payload_selector = Mock()
     pl = {"a": True}
     base.submit_payload(pl)
     base._append_payload_to_current_batch.assert_called_once_with(pl)
     base._flush_payload_selector.assert_called_once()
Ejemplo n.º 5
0
 def test_when_payload_is_over_byte_size(self):
     base = BaseDispatcher('test_subject',
                           'send_lots',
                           'send_one',
                           max_batch_size=1)
     base._aws_service_message_max_bytes = 10
     base._aws_service_batch_max_bytes = 15
     base._append_payload_to_current_batch = Mock()
     base._flush_payload_selector = Mock()
     pl = {"a": True}
     with self.assertRaises(ValueError) as context:
         base.submit_payload(pl)
     self.assertIn("exceeds the maximum payload size",
                   str(context.exception))
     base._append_payload_to_current_batch.assert_not_called()
     base._flush_payload_selector.assert_not_called()