"""Test for ows_track model.""" from models import ows_track import pytest from models.api_exceptions import PersistentException def test_get_track_info_success( mocker, get_track_info_success_response, track_id, get_track_info_fixture): """Test get track info from ows-track.""" mocker.patch( 'requests.get', return_value=get_track_info_success_response) result = ows_track.get_track_info(track_id) assert result == get_track_info_fixture def test_get_track_info_error( mocker, ows_error_response, track_id): """Test get track info from ows-track error.""" mocker.patch('requests.get', return_value=ows_error_response) with pytest.raises(PersistentException): ows_track.get_track_info(track_id) def test_update_track_info_success( mocker, get_track_info_success_response, get_track_info_fixture, track_id): """Test update_track_info to ows-track.""" mocker.patch( 'requests.put', return_value=get_track_info_success_response) result = ows_track.update_track_info(track_id, get_track_info_fixture) assert result == get_track_info_fixture def test_update_track_info_error( mocker, ows_error_response, get_track_info_fixture, track_id): """Test update_track_info to ows-track error.""" mocker.patch('requests.put', return_value=ows_error_response) with pytest.raises(PersistentException): ows_track.update_track_info(track_id, get_track_info_fixture) def test_update_track_contributor_success( mocker, update_track_contributor_success_response, track_artist_fixture, track_id ): """Test update_track_contributor to ows-track.""" mocker.patch( 'requests.patch', return_value=update_track_contributor_success_response ) result = ows_track.update_track_contributor( track_id, track_artist_fixture['type'], track_artist_fixture['track_artist_id'], track_artist_fixture ) assert result == track_artist_fixture def test_update_track_contributor_error( mocker, ows_error_response, track_artist_fixture, track_id): """Test update_track_contributor to ows-track error.""" mocker.patch('requests.patch', return_value=ows_error_response) with pytest.raises(PersistentException): ows_track.update_track_contributor( track_id, track_artist_fixture['type'], track_artist_fixture['track_artist_id'], track_artist_fixture )