"""ows-notifications connector tests.""" from unittest.mock import MagicMock import pytest import requests import config from src.connectors.ows_notifications import SERVICE_NAME, send_request def test_send_request_success(mocker): """Test send request success.""" mock_response = MagicMock(spec=requests.Response) mock_process = mocker.patch('src.connectors.ows_notifications.ows_request.process', return_value=mock_response) result = send_request('POST', '/test-path', json={'key': 'value'}) mock_process.assert_called_once_with( config.APPLICATION_NAME, config.ENVIRONMENT, 'POST', SERVICE_NAME, '/test-path', json={'key': 'value'} ) mock_response.raise_for_status.assert_called_once() assert result is mock_response def test_send_request_failure(mocker): """Test send request failure.""" mock_response = MagicMock(spec=requests.Response) mock_response.raise_for_status.side_effect = requests.exceptions.HTTPError('404 Client Error: Not Found for url') mocker.patch('src.connectors.ows_notifications.ows_request.process', return_value=mock_response) with pytest.raises(requests.exceptions.HTTPError) as excinfo: send_request('GET', '/not-found') assert '404 Client Error' in str(excinfo.value)