"""Lambda test module.""" from unittest.mock import patch from content_utils.exceptions import InvalidMessageException from openmock import openmock import pytest @openmock @patch('src.app.patch_product') def test_handler(mock_update, mock_event): """Test handler function.""" from src import app result = app.handler(mock_event, None) assert result == {'status': 'success'} @openmock @patch('src.app.patch_product') def test_handler_error(mock_update, mock_event): """Test handler function error.""" from src import app mock_update.side_effect = Exception('foo') with pytest.raises(Exception) as e: app.handler(mock_event, None) assert e.value.args[0] == 'foo' @openmock @patch('src.app.os_connector') def test_patch_product(mock_os): """Test patch_product.""" from src import app app.patch_product({'foo': 'bar'}) mock_os.patch_product.assert_called_with({'foo': 'bar'}) @openmock @patch('src.app.os_connector') def test_patch_product_error(mock_os): """Test patch_product error.""" from src import app with pytest.raises(InvalidMessageException) as e: app.patch_product(None) assert e.value.args[0] == 'Invalid message structure: Missing payload' assert mock_os.patch_product.call_count == 0