"""Conftest.""" import json import os from bulk_metadata_ingester_common.models.bulk_release import BulkRelease import pytest KEY = os.environ.get('KEY', 'generated_json/BMI TESTING V4 - Fluve Delta V2 R10T16_2023-05-02.json') # noqa BUCKET = os.environ.get('BUCKET', 'qa-bulk-metadata-ingester') ITEM_INDEX = '7892920192308_____991405286999' DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data',) def get_json(json_file='eleven_releases.json'): """Get JSON helper method.""" with open(os.path.join(DATA_DIR, json_file)) as fd: return fd.read() @pytest.fixture def test_release_json(json_file='eleven_releases.json'): """Parse given XML file using xmltodict.parse().""" return get_json(json_file) @pytest.fixture def test_event(): """JSON representing a single release event.""" return { 'key': KEY, 'bucket': BUCKET, 'item_index': ITEM_INDEX, 'execution_name': 'bulk-metadata-9f749c8d-7371-49d2-a5fe-772c2f0eafd6', 'state_machine_name': 'sfn-bulk-metadata-ingester', 'correlation_id': '72dd36af-50ad-42e4-9a61-4e5378434264', 'release': { 'subaccount_id': 0, 'project_artist_id': '3002836', 'participants': [ { 'name': 'Rosário Negro', 'artist_id': '3002836', 'label_participant_id': '1682997067932', 'label_participant_uuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66' # noqa }, { 'name': 'Tico Paranhios', 'artist_id': '3002837', 'label_participant_id': '1682997068346', 'label_participant_uuid': '67929c56-9ee6-4816-a758-7e442a88e072' # noqa }, { 'name': 'Jova', 'artist_id': '3002831', 'label_participant_id': '1682996945583', 'label_participant_uuid': 'acd6fa5d-6802-47da-8ff4-29b28a1fcb77' # noqa }, { 'name': 'LYYA', 'artist_id': '3002832', 'label_participant_id': '1682996946040', 'label_participant_uuid': '48c58131-bcfd-4464-9d6e-5a4840267153' # noqa }, { 'name': 'Gustavo Schirmer', 'artist_id': '3002833', 'label_participant_id': '1682996946421', 'label_participant_uuid': 'dc817030-c453-4e2e-b767-44229305fd3b' # noqa }, { 'name': 'Diego Jovanholi', 'artist_id': '3002834', 'label_participant_id': '1682996946787', 'label_participant_uuid': '27bf42f9-df41-4c72-96a8-b25742226bc2' # noqa }, { 'name': 'Lia Gabriela Balby', 'artist_id': '3002835', 'label_participant_id': '1682996947148', 'label_participant_uuid': '175a6534-040a-41e6-bf91-59df1d6e9dca' # noqa } ], 'project_id': 5471286, 'product_id': 4436528, 'upc': '197188854119' }, 'tracks': {} } @pytest.fixture def test_model(json_file='eleven_releases.json'): """Named Tuple model representing a release.""" test_json = json.loads(get_json())[ITEM_INDEX] return BulkRelease(json_release_rows=test_json) @pytest.fixture def test_track(test_model): """Named Tuple model representing a release.""" # Get a track from the test data model track_key = 'BCL0B2000004_1_1' # Get a track from the model track = test_model.tracks[track_key] return track @pytest.fixture def test_get_orchard_tracks_response(): """Response from get_orchard_tracks() when there are tracks.""" return [ { 'isrc': 'BCL0B2000004', 'tuid': '39311597' }, { 'isrc': 'BCL0B2100001', 'tuid': '39311598' }, { 'isrc': 'BCL0B2000007', 'tuid': '39311599' }, { 'isrc': 'BCL0B2100002', 'tuid': '39311600' }, { 'isrc': 'BCL0B2200001', 'tuid': '39311601' }, { 'isrc': 'BCL0B2200004', 'tuid': '39311602' } ] @pytest.fixture def test_get_empty_orchard_tracks_response(): """Response from get_orchard_tracks() when there are NO tracks.""" return [] @pytest.fixture def test_get_track_participants_response(): """Response from track query.""" return { 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'artists': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', 'role': 'WRITER' } ] } @pytest.fixture def test_get_all_roles_response(): """Response from track query.""" return { 'artists': [ { 'name': 'Rosário Negro', 'role': 'PERFORMER' }, { 'name': 'Tico Paranhios', 'role': 'PRODUCER' }, { 'name': 'Rosário Negro', 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'role': 'Vocals - Lead Vocals', 'type': 'primary' } ] } @pytest.fixture def test_format_create_track_data_response(): """Test fixture to create a sample track data response.""" return { 'upc': '197188854119', 'isrc': 'BCL0B2000004', 'volumeNumber': 1, 'trackNumber': 1, 'trackName': 'Sentido da Vida', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'recordingCountryId': 123, 'originalRightsHolderCountryId': 123, 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [ ], 'version': '' } @pytest.fixture def test_create_tracks_response(): """Response from track query.""" return [ { 'isrc': 'BCL0B2000004', 'tuid': '39311597', 'volumeNumber': 1, 'trackNumber': 1 }, { 'isrc': 'BCL0B2100001', 'tuid': '39311598', 'volumeNumber': 1, 'trackNumber': 2 }, { 'isrc': 'BCL0B2000007', 'tuid': '39311599', 'volumeNumber': 1, 'trackNumber': 3 }, { 'isrc': 'BCL0B2100002', 'tuid': '39311600', 'volumeNumber': 1, 'trackNumber': 4 }, { 'isrc': 'BCL0B2200001', 'tuid': '39311601', 'volumeNumber': 1, 'trackNumber': 5 }, { 'isrc': 'BCL0B2200004', 'tuid': '39311602', 'volumeNumber': 1, 'trackNumber': 6 } ] @pytest.fixture def test_label_participant_uuid(): """Fixture for label participant UUID.""" return '123' @pytest.fixture def test_performer(): """Fixture for performer data.""" return { 'role': 'PERFORMER', 'name': 'Pedro Libe' } @pytest.fixture def test_track_performers_result(): """Fixture for track performers data.""" return [ { 'labelParticipantUuid': '123', 'role': 'PERFORMER', }, { 'labelParticipantUuid': '5678', 'role': 'PRODUCER' } ] @pytest.fixture def test_add_track_performers(): """Track performers stub.""" return { 'performers': [ { 'name': 'Rosário Negro', 'role': 'Vocals - Lead Vocals', 'type': 'primary' }, { 'name': 'Joyy', 'role': 'Wind Instruments - Bassoon', 'type': 'featured' }, ] } @pytest.fixture def test_add_track_performers_result(): """Track performers result stub.""" return { 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' }, { 'name': 'Joyy', 'roleId': 95, 'type': 'featured' }, ] } @pytest.fixture def test_all_roles_result(): """Test get_all_roles() result.""" return { 'artists': [ { 'role': 'PERFORMER', 'name': 'Rosário Negro' }, { 'role': 'PRODUCER', 'name': 'Tico Paranhios' }, { 'role': 'WRITER', 'name': 'Rosário Negro' } ], 'performers': [ { 'role': 'Vocals - Lead Vocals', 'name': 'Rosário Negro', 'type': 'primary' } ] } @pytest.fixture def test_create_tracks_payload(): """Response from track query.""" return { 'data': { 'create': { 'productId': 4436528, 'tracks': [ { 'upc': '197188854119', 'isrc': 'BCL0B2000004', 'volumeNumber': 1, 'trackNumber': 1, 'trackName': 'Sentido da Vida', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', # noqa 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [], 'version': '' }, { 'upc': '197188854119', 'isrc': 'BCL0B2100001', 'volumeNumber': 1, 'trackNumber': 2, 'trackName': 'Abba', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', # noqa 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [], 'version': '' }, { 'upc': '197188854119', 'isrc': 'BCL0B2000007', 'volumeNumber': 1, 'trackNumber': 3, 'trackName': 'Pai & Filho', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', # noqa 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [], 'version': '' }, { 'upc': '197188854119', 'isrc': 'BCL0B2100002', 'volumeNumber': 1, 'trackNumber': 4, 'trackName': 'Em Teus Passos', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', # noqa 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [], 'version': '' }, { 'upc': '197188854119', 'isrc': 'BCL0B2200001', 'volumeNumber': 1, 'trackNumber': 5, 'trackName': 'Prova de Amor', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', # noqa 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [], 'version': '' }, { 'upc': '197188854119', 'isrc': 'BCL0B2200004', 'volumeNumber': 1, 'trackNumber': 6, 'trackName': 'O Princípio', 'metaLanguageCode': 'POR', 'explicit': 'N', 'pInfo': '2023 Rosário Negro', 'lyrics': '', 'ownershipRights': 'no_rights', 'participations': [ { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'PERFORMER' }, { 'labelParticipantUuid': '67929c56-9ee6-4816-a758-7e442a88e072', # noqa 'role': 'PRODUCER' }, { 'labelParticipantUuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66', # noqa 'role': 'WRITER' } ], 'performers': [ { 'name': 'Rosário Negro', 'roleId': 89, 'type': 'primary' } ], 'publishers': [], 'version': '' } ] } } } @pytest.fixture def test_handler_response(): """Response from track query.""" return { 'key': KEY, 'bucket': BUCKET, 'item_index': ITEM_INDEX, 'execution_name': 'bulk-metadata-9f749c8d-7371-49d2-a5fe-772c2f0eafd6', 'state_machine_name': 'sfn-bulk-metadata-ingester', 'correlation_id': '72dd36af-50ad-42e4-9a61-4e5378434264', 'release': { 'subaccount_id': 0, 'project_artist_id': '3002836', 'participants': [ { 'name': 'Rosário Negro', 'artist_id': '3002836', 'label_participant_id': '1682997067932', 'label_participant_uuid': '02b95897-49c9-49f9-b4f4-6127f48b4c66' # noqa }, { 'name': 'Tico Paranhios', 'artist_id': '3002837', 'label_participant_id': '1682997068346', 'label_participant_uuid': '67929c56-9ee6-4816-a758-7e442a88e072' # noqa }, { 'name': 'Jova', 'artist_id': '3002831', 'label_participant_id': '1682996945583', 'label_participant_uuid': 'acd6fa5d-6802-47da-8ff4-29b28a1fcb77' # noqa }, { 'name': 'LYYA', 'artist_id': '3002832', 'label_participant_id': '1682996946040', 'label_participant_uuid': '48c58131-bcfd-4464-9d6e-5a4840267153' # noqa }, { 'name': 'Gustavo Schirmer', 'artist_id': '3002833', 'label_participant_id': '1682996946421', 'label_participant_uuid': 'dc817030-c453-4e2e-b767-44229305fd3b' # noqa }, { 'name': 'Diego Jovanholi', 'artist_id': '3002834', 'label_participant_id': '1682996946787', 'label_participant_uuid': '27bf42f9-df41-4c72-96a8-b25742226bc2' # noqa }, { 'name': 'Lia Gabriela Balby', 'artist_id': '3002835', 'label_participant_id': '1682996947148', 'label_participant_uuid': '175a6534-040a-41e6-bf91-59df1d6e9dca' # noqa } ], 'project_id': 5471286, 'product_id': 4436528, 'upc': '197188854119' }, 'tracks': { 'BCL0B2000004_1_1': { 'tuid': '39311597' }, 'BCL0B2100001_1_2': { 'tuid': '39311598' }, 'BCL0B2000007_1_3': { 'tuid': '39311599' }, 'BCL0B2100002_1_4': { 'tuid': '39311600' }, 'BCL0B2200001_1_5': { 'tuid': '39311601' }, 'BCL0B2200004_1_6': { 'tuid': '39311602' } } } @pytest.fixture def graphql_response(): """Response from track query.""" return { 'data': { 'track': { 'trackNumber': 1, 'trackName': 'first', 'version': None, 'explicit': 'C', 'metaLanguageCode': 'ENG', 'lyrics': 'track lyrics', 'pInfo': '2018 Sony Music Associated Records', 'primaryArtists': [ {'artistName': 'Giveon', 'artistType': 'performer'}, {'artistName': 'Artist', 'artistType': 'featuring'}, {'artistName': 'Resource Contributor Producer', 'artistType': 'producer'} # noqa ], 'writers': [ {'name': 'Composer Name', 'type': 'writer'}, {'name': 'ComposerLyricist Name', 'type': 'writer'}, {'name': 'StudioMusician Name', 'type': 'writer'}, {'name': 'VocalEngineer Name', 'type': 'writer'}, ], 'performers': [ {'name': 'PrimaryMusician Name', 'roleId': 27, 'type': 'primary'}, # noqa {'name': 'PrimaryMusician Name', 'roleId': 129, 'type': 'primary'}, # noqa {'name': 'BackgroundVocalist Name', 'roleId': 74, 'type': 'primary'}, # noqa {'name': 'StudioMusician Name', 'roleId': 27, 'type': 'non-featured'}, # noqa {'name': 'StudioMusician Name', 'roleId': 10, 'type': 'non-featured'}, # noqa ], 'labelSoundRecording': { 'participations': [ { 'role': {'name': 'Vocal Engineer'}, # noqa 'participant': {'id': '82', 'name': 'VocalEngineer Name'} # noqa }, { 'role': {'name': 'A & R Administrator'}, 'participant': {'id': '72', 'name': 'StudioMusician Name'} # noqa }, { 'role': {'name': 'A & R Coordinator'}, 'participant': {'id': '72', 'name': 'StudioMusician Name'} # noqa }, { 'role': {'name': 'Recording Engineer'}, 'participant': {'id': '102', 'name': 'Resource Contributor Producer'} # noqa } ], }, } } }