Ejemplo n.º 1
0
    def test_equals_max(self, mock_get_byte_size_of_dict_or_list):
        base = BaseDispatcher('test_subject',
                              'send_lots',
                              'send_one',
                              max_batch_size=1)
        base._aws_service_message_max_bytes = 1
        mock_get_byte_size_of_dict_or_list.return_value = 1
        test_pl = {'stuff': True}

        base._validate_payload_byte_size(test_pl)

        mock_get_byte_size_of_dict_or_list.assert_has_calls(
            [call({}), call(test_pl)], any_order=True)
Ejemplo n.º 2
0
    def test_more_than_max(self, mock_get_byte_size_of_dict_or_list):
        base = BaseDispatcher('test_subject',
                              'send_lots',
                              'send_one',
                              max_batch_size=1)
        base._aws_service_message_max_bytes = 1
        mock_get_byte_size_of_dict_or_list.return_value = 2
        test_pl = {'stuff': True}

        with self.assertRaises(ValueError) as context:
            base._validate_payload_byte_size(test_pl)
        self.assertIn("exceeds the maximum payload size",
                      str(context.exception))

        mock_get_byte_size_of_dict_or_list.assert_has_calls(
            [call({}), call(test_pl)], any_order=True)
Ejemplo n.º 3
0
 def test_when_payload_is_equal_to_byte_size(self):
     base = BaseDispatcher('test_subject',
                           'send_lots',
                           'send_one',
                           max_batch_size=1)
     base._aws_service_message_max_bytes = 11
     base._aws_service_batch_max_bytes = 15
     base._validate_payload_byte_size = Mock(return_value=True)
     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()