"""Tests for ows_artist model.""" from unittest.mock import MagicMock import pytest import requests import const # noqa import index # noqa from models import ows_artist def test_get_artist_document( mocker, artist_document_fixture): """Test get artist info from ows-artist successfully.""" mocker.patch( 'requests.get', return_value=MagicMock( spec=requests.models.Response, status_code=200, json=lambda: artist_document_fixture)) result = ows_artist.get_artist_document(55555) assert result == artist_document_fixture def test_get_artist_document_not_found(mocker, ows_not_found_response): """Test get artist data from ows-artist not found.""" mocker.patch( 'requests.get', return_value=ows_not_found_response) result = ows_artist.get_artist_document(55555) assert result == {} def test_get_artist_document_error(mocker, ows_error_response): """Test get artist data from ows-artist error.""" mocker.patch( 'requests.get', return_value=ows_error_response) with pytest.raises(Exception, match=const.OWS_ARTIST_ERROR): ows_artist.get_artist_document(55555)