"""Functional tests for updating a track artist role for all tracks in product. Test endpoint: POST /product//tracks/change_genre """ import json from oto import status as response_code from backend.constants import artist_role from tests.testutils import db @db.test_schema def test_valid_artist_roles_for_classical( client_update_artist_role_by_genre, track_artist_role_update_request_classical, test_product_id): """Test valid roles for classical genre.""" res = client_update_artist_role_by_genre( product_id=test_product_id, data=track_artist_role_update_request_classical) res_body = json.loads(res.data.decode()) assert res.status_code == response_code.OK res_roles = [artist.get('type') for artist in res_body] assert (role in artist_role.CLASSICAL_ARTIST_ROLES for role in res_roles) @db.test_schema def test_valid_artist_roles_for_nonclassical( client_update_artist_role_by_genre, track_artist_role_update_request_nonclassical, test_product_id): """Test valid roles for non-classical genre.""" res = client_update_artist_role_by_genre( product_id=test_product_id, data=track_artist_role_update_request_nonclassical) res_body = json.loads(res.data.decode()) assert res.status_code == response_code.OK res_roles = [artist.get('type') for artist in res_body] assert (role in artist_role.NON_CLASSICAL_ARTIST_ROLES for role in res_roles) @db.test_schema def test_valid_artist_roles_for_classical_with_profile( client_update_artist_role_by_genre_with_profile, track_artist_role_update_request_classical, test_product_id): """Test valid roles for classical genre.""" res = client_update_artist_role_by_genre_with_profile( product_id=test_product_id, data=track_artist_role_update_request_classical) res_body = json.loads(res.data.decode()) assert res.status_code == response_code.OK res_roles = [artist.get('type') for artist in res_body] assert (role in artist_role.CLASSICAL_ARTIST_ROLES for role in res_roles)