class_docstr: Tests for merger/main.py:AlertMerger class
class_docstr_tok: ["Tests","for","merger\/main.py",":","AlertMerger","class"]
docstr: Alert Merger - Sorted Alerts - Invalid Alerts are Logged
docstr_tok: ["Alert","Merger","-","Sorted","Alerts","-","Invalid","Alerts","are","Logged"]
code: def test_alert_generator(self, mock_logger):
      """Alert Merger - Sorted Alerts - Invalid Alerts are Logged"""
      records = [
          Alert("test_rule", {}, {"output"}).dynamo_record(),
          {"Nonsense": "Record"},
      ]
  
      with patch.object(
          self.merger.table, "get_alert_records", return_value=records
      ):
          result = list(self.merger._alert_generator("test_rule"))
          # Valid record is returned
          assert_equal(1, len(result))
          assert_equal(records[0]["AlertID"], result[0].alert_id)
          # Invalid record logs an exception
          mock_logger.exception.assert_called_once_with(
              "Invalid alert record %s", records[1]
          )
  
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 3 for calling the TestAlertMerger obj's underlying member method code with example usage: obj.test_alert_generator(mock_logger) without return types