"""Test logging errors.""" import pytest from reserves_release.error_handling import OwsServiceException from reserves_release.error_handling import raise_service_error def test_raise_service_error(): """Test _raise_service_error logs error and raises exception.""" data = { 'target_id': 2, } error_msg = 'ERROR to GET /service/path/' service = 'ows-service' with pytest.raises(OwsServiceException) as e: raise_service_error(error_msg, service, **data) assert f'POST to {service} failed' in str(e.value) def test_raise_service_error_no_kwargs(): """Test _raise_service_error logs error and raises exception without kwargs.""" error_msg = 'ERROR to GET /service/path/id/' service = 'ows-service' with pytest.raises(OwsServiceException) as e: raise_service_error(error_msg, service) assert f'{service} failure: {error_msg}' in str(e.value)