"""Lambda test module.""" from unittest.mock import patch import pytest from app import handler @patch('app.ReservesScheduleProcessor') def test_handler(mock_processor, mock_accounting_run_event): """Test handler function.""" result = handler(mock_accounting_run_event, None) assert result == {'status': 'OK'} mock_processor.assert_called_once_with(mock_accounting_run_event) @patch('app.sentry_sdk') @patch('app.ReservesScheduleProcessor.process') def test_handler_exception( mock_processor, mock_capture_exception, mock_accounting_run_event ): """Test handler catches Exception.""" mock_capture_exception.return_value = True mock_processor.side_effect = Exception('key error') with pytest.raises(Exception) as e: handler(mock_accounting_run_event, None) mock_capture_exception.assert_called_once_with(e)