"""Lambda test module.""" from unittest.mock import patch import pytest from src import app @patch('src.app.publish_review_event') def test_handler_success(mock_publish, mock_event): """Test handler function.""" result = app.handler(mock_event, None) assert mock_publish.call_count == 1 assert result == {'status': 'success'} @patch('src.app.publish_review_event') def test_handler_error(mock_publish, mock_event): """Test handler function.""" mock_publish.side_effect = Exception('foo') with pytest.raises(Exception): app.handler(mock_event, None) assert mock_publish.call_count == 1 @patch('src.app.publish_review_event') def test_handler_does_nothing(mock_publish): """Test that the handler does nothing if the skip flag is set.""" actual = app.handler({'product_id': 1, 'skip_kafka_event': True}, None) assert actual == {'status': 'success'} mock_publish.assert_not_called()