"""Ows-notifications tests.""" from unittest.mock import patch from owsrequest.test_utils import MockOwsResponse import pytest from config import ENVIRONMENT from src.models import ows_notifications @pytest.mark.parametrize( 'response, should_raise', [ (MockOwsResponse(200, [{ 'feed_type': 'social_spike', 'notification_type': 'push_notifications' }]), False), (MockOwsResponse(404, []), False), (MockOwsResponse(500, []), True), ] ) @patch('owsrequest.request.process') def test_get_notification_settings(owsrequest_mock, response, should_raise): """Test get notification settings from ows-notifications.""" profile_type, profile_id = 'LabelProfile', '123' owsrequest_mock.return_value = response raised = False try: settings = ows_notifications.get_notification_settings( profile_id, profile_type) assert settings == response.json() except Exception: raised = True owsrequest_mock.assert_called_with( 'lambda-notifications-publish-message', ENVIRONMENT, 'GET', 'ows-notifications', f'/profile/profile_id/{profile_id}' f'/profile_type/{profile_type}/notifications') assert should_raise == raised