"""Ows-users tests.""" from unittest.mock import patch from owsrequest.test_utils import MockOwsResponse import pytest from config import ENVIRONMENT from src.models import ows_users @pytest.mark.parametrize( 'response, should_raise', [ (MockOwsResponse(200, {}), False), (MockOwsResponse(404, {}), False), (MockOwsResponse(500, {}), True) ] ) @patch('owsrequest.request.process') def test_get_identity(owsrequest_mock, response, should_raise): """Test get identity from ows-users.""" profile_type, profile_id = 'LabelProfile', '123' owsrequest_mock.return_value = response raised = False try: ows_users.get_identity(profile_id, profile_type) except Exception: raised = True owsrequest_mock.assert_called_with( 'lambda-notifications-publish-message', ENVIRONMENT, 'GET', 'ows-users', f'/profile/profile_id/{profile_id}/profile_type/{profile_type}/identity' # noqa:E501 ) assert should_raise == raised