"""Lambda test module.""" from unittest.mock import patch import pytest from index import handler @patch('index.AccountingPeriodCloseProcessor') def test_handler(mock_processor, mock_event): """Test handler function.""" result = handler(mock_event, None) assert result == {'status': 'OK'} mock_processor.assert_called_once_with(mock_event) @patch('index.capture_exception') @patch('index.AccountingPeriodCloseProcessor.process') def test_handler_exception(mock_processor, mock_capture_exception, mock_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_event, None) mock_capture_exception.assert_called_once_with(e)