コード例 #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)
コード例 #2
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()
コード例 #3
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)
コード例 #4
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()