class_docstr: Tests for merger/main.py:AlertMerger class
class_docstr_tok: ["Tests","for","merger\/main.py",":","AlertMerger","class"]
docstr: Alert Merger - Dispatch to Alert Processor Lambda
docstr_tok: ["Alert","Merger","-","Dispatch","to","Alert","Processor","Lambda"]
code: def test_dispatch(self, mock_logger):
      """Alert Merger - Dispatch to Alert Processor Lambda"""
      self.merger.lambda_client = MagicMock()
  
      self.merger.table.add_alerts(
          [
              # An alert without any merge criteria
              Alert("no_merging", {}, {"output"}),
              # 2 Alerts which will be merged (and will be be too large to send the entire record)
              Alert(
                  "merge_me",
                  {"key": True},
                  {"output"},
                  created=datetime(year=2000, month=1, day=1),
                  merge_by_keys=["key"],
                  merge_window=timedelta(minutes=5),
              ),
              Alert(
                  "merge_me",
                  {"key": True, "other": "abc" * 50},
                  {"output"},
                  created=datetime(year=2000, month=1, day=1, minute=1),
                  merge_by_keys=["key"],
                  merge_window=timedelta(minutes=5),
              ),
              # Alert which has already sent successfully (will be deleted)
              Alert(
                  "already_sent",
                  {},
                  {"output"},
                  outputs_sent={"output"},
              ),
          ]
      )
  
      self.merger.dispatch()
      # NOTE (Bobby): The following assertion was modified during the py2 -> py3
      # conversion to disregard order of calls.
      mock_logger.assert_has_calls(
          [
              call.info(
                  "Merged %d alerts into a new alert with ID %s", 2, ANY
              ),
              call.info(
                  "Dispatching %s to %s (attempt %d)",
                  ANY,
                  _ALERT_PROCESSOR,
                  1,
              ),
              call.info(
                  "Dispatching %s to %s (attempt %d)",
                  ANY,
                  _ALERT_PROCESSOR,
                  1,
              ),
          ],
          any_order=True,
      )
  
imports: from datetime import datetime, timedelta
  import os
  from mock import ANY, call, patch, MagicMock
  from moto import mock_dynamodb2, mock_lambda
  from nose.tools import assert_equal, assert_false, assert_true
  from streamalert.alert_merger import main
  from streamalert.shared.alert import Alert
  from tests.unit.helpers.aws_mocks import create_lambda_function, setup_mock_alerts_table
label_desc: Use image node_id 8 for calling the TestAlertMerger obj's underlying member method code with example usage: obj.test_dispatch(mock_logger) without return types