예제 #1
0
 def test_happy_path(self):
     dy = DynamoBatchDispatcher('test_table_name',
                                'p_key',
                                max_batch_size=1)
     dy._dynamo_table = Mock()
     dy._dynamo_table.put_item = Mock()
     test_payload = {"processed_payload": False}
     dy._send_individual_payload(test_payload)
     dy._dynamo_table.put_item.assert_called_once_with(
         **{'Item': test_payload})
예제 #2
0
 def test_client_error_no_retries_remaining(self):
     dy = DynamoBatchDispatcher('test_table_name',
                                'p_key',
                                max_batch_size=1)
     dy._dynamo_table = Mock()
     dy._dynamo_table.put_item.side_effect = [
         ClientError({'Error': {
             'Code': 500,
             'Message': 'broken'
         }}, "Dynamo")
     ]
     test_payload = {"processed_payload": False}
     dy._send_individual_payload(test_payload, retry=0)
     dy._dynamo_table.put_item.assert_called_once_with(
         **{'Item': test_payload})
     self.assertEqual([test_payload], dy.unprocessed_items)
예제 #3
0
 def test_client_error_retries_remaining(self):
     dy = DynamoBatchDispatcher('test_table_name',
                                'p_key',
                                max_batch_size=1)
     dy._dynamo_table = Mock()
     dy._dynamo_table.put_item.side_effect = [
         ClientError({'Error': {
             'Code': 500,
             'Message': 'broken'
         }}, "Dynamo"), None
     ]
     test_payload = {"processed_payload": False}
     dy._send_individual_payload(test_payload, retry=1)
     dy._dynamo_table.put_item.assert_has_calls(
         [call(**{'Item': test_payload}),
          call(**{'Item': test_payload})])