"""Lambda test module.""" from unittest.mock import patch import pytest import index @patch('index.CommitAdjustmentProcessor') def test_handler(mock_processor, mock_event): """Test handler function.""" result = index.handler(mock_event, None) assert result == {'status': 'OK'} mock_processor.side_effect = ValueError('foo') with pytest.raises(ValueError) as e: index.handler(mock_event, None) assert str(e) == 'foo' @patch('index.CommitAdjustmentProcessor') @patch('index.capture_exception', return_value=True) def test_sentry(sentry_mock, processor_mock): """Test sentry is called.""" exception = KeyError('foo') processor_mock.return_value.process.side_effect = exception with pytest.raises(exception.__class__): index.handler({'Records': []}, None) sentry_mock.assert_called_with(exception)