"""Shared text fixtures.""" import base64 import json from copy import copy from unittest.mock import MagicMock from requests import Session import pytest import requests class SessionMock(object): """Objects that returns true when compared with a Session object.""" def __eq__(self, other): """Return true if compared with a Session object.""" return isinstance(other, Session) def __ne__(self, other): """Return true if compared with a non-Session object.""" return not self.__eq__(other) def __repr__(self): """Official string representation of mock Session object.""" return '' @pytest.fixture def session(): """Mock session fixture.""" return SessionMock() @pytest.fixture def track_id(): """Track ID fixture.""" return 175962 @pytest.fixture def track_artist_db_row(track_id, artist_name): """Row from art_relations.track_artist.""" return { 'id': 1, 'track_id': track_id, 'type': 'performer', 'name': artist_name, 'artist_info_id': None } @pytest.fixture def blank_track_artist_db_row(track_id): """Row from art_relations.track_artist with blank name.""" return { 'id': 1, 'track_id': track_id, 'type': 'performer', 'name': '', 'artist_info_id': None } @pytest.fixture def blank_track_writer_db_row(track_id): """Row from art_relations.track_writer with blank name.""" return { 'track_writer_id': 1, 'unique_track_id': track_id, 'track_id': 1, 'cd': 1, 'upc': 669910539255, 'writer_name': '', 'artist_info_id': None } @pytest.fixture def track_writer_db_row(track_id, artist_name): """Row from art_relations.track_writer.""" return { 'track_writer_id': 1, 'unique_track_id': track_id, 'track_id': 1, 'cd': 1, 'upc': 669910539255, 'writer_name': artist_name, 'artist_info_id': None } @pytest.fixture def track_writer_db_row_with_artist_info_id(track_id, artist_name): """Row from art_relations.track_writer with artist_info_id.""" return { 'track_writer_id': 1, 'unique_track_id': track_id, 'track_id': 1, 'cd': 1, 'upc': 669910539255, 'writer_name': artist_name, 'artist_info_id': 1 } @pytest.fixture def track_artist_db_row_with_artist_info_id(track_id, artist_name): """Row from art_relations.track_artist with artist_info_id.""" return { 'id': 1, 'track_id': track_id, 'type': 'performer', 'name': artist_name, 'artist_info_id': 1 } @pytest.fixture def product_id(): """Product ID fixture.""" return 2104178 @pytest.fixture def product_name(): """Product name fixture.""" return 'Good Product' @pytest.fixture def vendor_account_type(): """Vendor account type fixture.""" return 'vendor' @pytest.fixture def release_artist_db_row(product_id, artist_name): """Row from art_relations.release_artist.""" return { 'release_artist_id': 1, 'upc': 669910539255, 'role': 'performer', 'release_id': product_id, 'artist_name': artist_name, 'url': None, 'artist_info_id': None } @pytest.fixture def release_artist_db_row_with_artist_info_id(product_id, artist_name): """Row from art_relations.release_artist with artist_info_id value.""" return { 'release_artist_id': 1, 'upc': 669910539255, 'role': 'performer', 'release_id': product_id, 'artist_name': artist_name, 'url': None, 'artist_info_id': 1 } @pytest.fixture def release_artist_maxwells_event_fixture(release_artist_db_row): """Release artist row event from Maxwell's Daemon.""" row = copy(release_artist_db_row) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'release_artist', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.release_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def track_artist_maxwells_event_fixture(track_artist_db_row): """Track artist row event from Maxwell's Daemon.""" row = copy(track_artist_db_row) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track_artist', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.release_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def blank_track_artist_maxwells_event_fixture(blank_track_artist_db_row): """Blank track artist row event from Maxwell's Daemon.""" row = copy(blank_track_artist_db_row) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track_artist', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.track_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def blank_track_writer_maxwells_event_fixture(blank_track_writer_db_row): """Blank track writer row event from Maxwell's Daemon.""" row = copy(blank_track_writer_db_row) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track_artist', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.track_writer', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def track_writer_maxwells_event_fixture(track_writer_db_row): """Track writer row event from Maxwell's Daemon.""" row = copy(track_writer_db_row) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track_writer', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.release_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def release_artist_maxwells_event_fixture_with_artist_info_id( release_artist_db_row_with_artist_info_id): """Release artist row event from Maxwell's Daemon with artist_info_id.""" row = copy(release_artist_db_row_with_artist_info_id) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'release_artist', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.release_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def track_artist_maxwells_event_fixture_with_artist_info_id( track_artist_db_row_with_artist_info_id): """Track artist row event from Maxwell's Daemon with artist_info_id.""" row = copy(track_artist_db_row_with_artist_info_id) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track_artist', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.release_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def track_writer_maxwells_event_fixture_with_artist_info_id( track_writer_db_row_with_artist_info_id): """Track writer row event from Maxwell's Daemon with artist_info_id.""" row = copy(track_writer_db_row_with_artist_info_id) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track_writer', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.release_artist', 'deleted': False, 'type': 'update-insert', '@uuid': '3c226027-d7fa-4247-baf0-5a49c74aff17', 'input_label': 'prod_art_relations', '@timestamp': '2017-08-28T11:03:22.949Z', 'input_type': 'mysql', 'input_id': '2ed58075-dfc9-409c-9587-5ab7738ca48f', 'restream_count': 1, '@parent_uuid': '' } return row @pytest.fixture def converted_release_artist_event_fixture( release_artist_maxwells_event_fixture): """Maxwell's Daemon release artist event converted to internal format.""" return { 'data': release_artist_maxwells_event_fixture, 'table': 'release_artist', 'type': 'insert' } @pytest.fixture def converted_release_artist_delete_event_fixture( release_artist_maxwells_event_fixture): """Maxwell's Daemon release artist event converted to internal format.""" return { 'data': release_artist_maxwells_event_fixture, 'table': 'release_artist', 'type': 'delete' } @pytest.fixture def converted_track_artist_event_fixture(track_artist_maxwells_event_fixture): """Maxwell's Daemon track artist event converted to internal format.""" return { 'data': track_artist_maxwells_event_fixture, 'table': 'track_artist', 'type': 'insert' } @pytest.fixture def converted_blank_track_artist_event_fixture( blank_track_artist_maxwells_event_fixture): """Maxwell's Daemon blank track artist converted to internal format.""" return { 'data': blank_track_artist_maxwells_event_fixture, 'table': 'track_artist', 'type': 'insert' } @pytest.fixture def converted_blank_track_writer_event_fixture( blank_track_writer_maxwells_event_fixture): """Maxwell's Daemon blank track writer converted to internal format.""" return { 'data': blank_track_writer_maxwells_event_fixture, 'table': 'track_writer', 'type': 'insert' } @pytest.fixture def converted_track_writer_event_fixture(track_writer_maxwells_event_fixture): """Maxwell's Daemon track writer event converted to internal format.""" return { 'data': track_writer_maxwells_event_fixture, 'table': 'track_writer', 'type': 'insert' } @pytest.fixture def converted_track_artist_delete_event_fixture( track_artist_maxwells_event_fixture): """Maxwell's Daemon track artist event converted to internal format.""" return { 'data': track_artist_maxwells_event_fixture, 'table': 'track_artist', 'type': 'delete' } @pytest.fixture def converted_track_writer_delete_event_fixture( track_writer_maxwells_event_fixture): """Maxwell's Daemon track writer event converted to internal format.""" return { 'data': track_writer_maxwells_event_fixture, 'table': 'track_writer', 'type': 'delete' } @pytest.fixture def converted_track_artist_update_event_fixture( track_artist_maxwells_event_fixture): """Maxwell's Daemon track artist event converted to internal format.""" event_fixture = track_artist_maxwells_event_fixture.copy() return { 'data': event_fixture, 'old': { 'name': 'Old Name' }, 'table': 'track_artist', 'type': 'update' } @pytest.fixture def converted_track_writer_update_event_fixture( track_writer_maxwells_event_fixture): """Maxwell's Daemon track writer event converted to internal format.""" event_fixture = track_writer_maxwells_event_fixture return { 'data': event_fixture, 'old': { 'writer_name': 'Old Name' }, 'table': 'track_writer', 'type': 'update' } @pytest.fixture def converted_release_artist_event_fixture_with_artist_info_id( release_artist_maxwells_event_fixture_with_artist_info_id): """Maxwell's Daemon release artist event with artist_info_id. Converted to internal format. """ return { 'data': release_artist_maxwells_event_fixture_with_artist_info_id, 'table': 'release_artist', 'type': 'insert' } @pytest.fixture def converted_track_artist_event_fixture_with_artist_info_id( track_artist_maxwells_event_fixture_with_artist_info_id): """Maxwell's Daemon track artist event with artist_info_id. Converted to internal format. """ return { 'data': track_artist_maxwells_event_fixture_with_artist_info_id, 'table': 'track_artist', 'type': 'insert' } @pytest.fixture def converted_track_artist_update_event_fixture_with_artist_info_id( track_artist_maxwells_event_fixture_with_artist_info_id): """Maxwell's Daemon track artist update event with artist_info_id. Converted to internal format. """ event_fixture = track_artist_maxwells_event_fixture_with_artist_info_id.copy() # noqa return { 'data': event_fixture, 'old': { 'name': 'Old Name' }, 'table': 'track_artist', 'type': 'update' } @pytest.fixture def converted_track_writer_event_fixture_with_artist_info_id( track_writer_maxwells_event_fixture_with_artist_info_id): """Maxwell's Daemon track writer event with artist_info_id. Converted to internal format. """ return { 'data': track_writer_maxwells_event_fixture_with_artist_info_id, 'table': 'track_writer', 'type': 'insert' } @pytest.fixture def converted_track_writer_update_event_fixture_with_artist_info_id( track_writer_maxwells_event_fixture_with_artist_info_id): """Maxwell's Daemon track writer update event with artist_info_id. Converted to internal format. """ event_fixture = track_writer_maxwells_event_fixture_with_artist_info_id.copy() # noqa return { 'data': event_fixture, 'old': { 'writer_name': 'Old Name' }, 'table': 'track_writer', 'type': 'update' } def kinesis_event_fixture(fixture): """Mock a Kinesis event.""" return { 'Records': [ { 'kinesis': { 'data': base64.b64encode( json.dumps(fixture).encode('utf8') ) } } ] } @pytest.fixture def release_artist_kinesis_event_fixture( converted_release_artist_event_fixture): """Release Artist Kinesis event fixture.""" return kinesis_event_fixture(converted_release_artist_event_fixture) @pytest.fixture def release_artist_kinesis_delete_event_fixture( converted_release_artist_delete_event_fixture): """Release Artist Kinesis delete event fixture.""" return kinesis_event_fixture(converted_release_artist_delete_event_fixture) @pytest.fixture def track_artist_kinesis_event_fixture( converted_track_artist_event_fixture): """Track Artist Kinesis event fixture.""" return kinesis_event_fixture(converted_track_artist_event_fixture) @pytest.fixture def blank_track_artist_kinesis_event_fixture( converted_blank_track_artist_event_fixture): """Blank Track Artist Kinesis event fixture.""" return kinesis_event_fixture(converted_blank_track_artist_event_fixture) @pytest.fixture def blank_track_writer_kinesis_event_fixture( converted_blank_track_writer_event_fixture): """Blank Track Writer Kinesis event fixture.""" return kinesis_event_fixture(converted_blank_track_writer_event_fixture) @pytest.fixture def track_artist_kinesis_delete_event_fixture( converted_track_artist_delete_event_fixture): """Track Artist Kinesis delete event fixture.""" return kinesis_event_fixture(converted_track_artist_delete_event_fixture) @pytest.fixture def track_artist_kinesis_update_event_fixture( converted_track_artist_update_event_fixture): """Track Artist update Kinesis event fixture.""" return kinesis_event_fixture(converted_track_artist_update_event_fixture) @pytest.fixture def track_writer_kinesis_event_fixture( converted_track_writer_event_fixture): """Track Writer Kinesis event fixture.""" return kinesis_event_fixture(converted_track_writer_event_fixture) @pytest.fixture def track_writer_kinesis_delete_event_fixture( converted_track_writer_delete_event_fixture): """Track Writer Kinesis delete event fixture.""" return kinesis_event_fixture(converted_track_writer_delete_event_fixture) @pytest.fixture def release_artist_with_artist_info_id_kinesis_event_fixture( converted_release_artist_event_fixture_with_artist_info_id): """Release Artist With Artist Info ID Kinesis event fixture.""" return kinesis_event_fixture( converted_release_artist_event_fixture_with_artist_info_id) @pytest.fixture def track_artist_with_artist_info_id_kinesis_event_fixture( converted_track_artist_event_fixture_with_artist_info_id): """Track Artist With Artist Info ID Kinesis event fixture.""" return kinesis_event_fixture( converted_track_artist_event_fixture_with_artist_info_id) @pytest.fixture def track_artist_with_artist_info_id_kinesis_update_event_fixture( converted_track_artist_update_event_fixture_with_artist_info_id): """Track Artist With Artist Info ID Kinesis event fixture.""" return kinesis_event_fixture( converted_track_artist_update_event_fixture_with_artist_info_id) @pytest.fixture def track_writer_with_artist_info_id_kinesis_event_fixture( converted_track_writer_event_fixture_with_artist_info_id): """Track Writer With Artist Info ID Kinesis event fixture.""" return kinesis_event_fixture( converted_track_writer_event_fixture_with_artist_info_id) @pytest.fixture def track_writer_with_artist_info_id_kinesis_update_event_fixture( converted_track_writer_update_event_fixture_with_artist_info_id): """Track Writer With Artist Info ID Kinesis event fixture.""" return kinesis_event_fixture( converted_track_writer_update_event_fixture_with_artist_info_id) @pytest.fixture def track_writer_kinesis_update_event_fixture( converted_track_writer_update_event_fixture): """Track Writer update event fixture.""" return kinesis_event_fixture(converted_track_writer_update_event_fixture) @pytest.fixture def artist_name(): """Artist name fixture.""" return 'Joe Rock' @pytest.fixture def release_artist_fixture(artist_name): """Release artist fixture.""" return { 'name': artist_name, 'id': 1, 'role': 'performer', 'artist_info_id': None } @pytest.fixture def track_artist_fixture(artist_name): """Track artist fixture.""" return { 'name': artist_name, 'track_artist_id': 1, 'type': 'performer', 'artist_info_id': None } @pytest.fixture def track_writer_fixture(artist_name): """Track writer fixture.""" return { 'name': artist_name, 'track_writer_id': 1, 'type': 'writer', 'artist_info_id': None } @pytest.fixture def track_writer_fixture_with_artist_info_id(artist_name): """Track writer fixture with an artist_info_id.""" return { 'name': artist_name, 'track_writer_id': 1, 'type': 'writer', 'artist_info_id': 1 } @pytest.fixture def track_artist_fixture_with_artist_info_id(artist_name): """Track artist fixture.""" return { 'name': artist_name, 'track_artist_id': 1, 'type': 'performer', 'artist_info_id': 1 } @pytest.fixture def release_artist_fixture_with_artist_info_id(artist_name): """Release artist fixture with an artist_info_id.""" return { 'name': artist_name, 'id': 1, 'role': 'performer', 'artist_info_id': 1 } @pytest.fixture def create_artist_fixture(artist_name): """Create_artist_info fixture.""" return { 'id': 1, 'name': artist_name, 'artist_type': 'artist' } @pytest.fixture def get_track_info_fixture(track_id, track_artist_fixture, product_id): """get_track_info fixture.""" return { 'tuid': track_id, 'product_id': product_id, 'track_name': 'Amazing Track', 'track_number': 1, 'volume_number': 1, 'p_info': '2017 Meow', 'ownership_rights': 'original_owner', 'recording_country_id': 1, 'localizations': [], 'meta_language_code': 'ZUN', 'explicit': 'N', 'preview_start_time': None, 'writers': [], 'artists': [track_artist_fixture], 'upc': 12345, 'original_rights_holder_country_id': 1 } @pytest.fixture def track_writer_get_track_info_fixture( track_id, track_writer_fixture, product_id): """get_track_info fixture.""" return { 'tuid': track_id, 'product_id': product_id, 'track_name': 'Amazing Track', 'track_number': 1, 'volume_number': 1, 'p_info': '2017 Meow', 'ownership_rights': 'original_owner', 'recording_country_id': 1, 'localizations': [], 'meta_language_code': 'ZUN', 'explicit': 'N', 'preview_start_time': None, 'writers': [track_writer_fixture], 'artists': [], 'upc': 12345, 'original_rights_holder_country_id': 1 } @pytest.fixture def update_track_info_fixture_with_artist_info_id( track_id, track_artist_fixture_with_artist_info_id, product_id): """update_track_info fixture with artist ID.""" return { 'tuid': track_id, 'product_id': product_id, 'track_name': 'Amazing Track', 'track_number': 1, 'volume_number': 1, 'p_info': '2017 Meow', 'ownership_rights': 'original_owner', 'isrc': '', 'recording_country_id': 1, 'localizations': [], 'meta_language_code': 'ZUN', 'explicit': 'N', 'preview_start_time': None, 'writers': [], 'artists': [track_artist_fixture_with_artist_info_id], 'upc': 12345, 'original_rights_holder_country_id': 1 } @pytest.fixture def writer_update_track_info_fixture_with_artist_info_id( track_id, track_writer_fixture_with_artist_info_id, product_id): """update_track_info fixture writers with artist ID.""" return { 'tuid': track_id, 'product_id': product_id, 'track_name': 'Amazing Track', 'track_number': 1, 'volume_number': 1, 'p_info': '2017 Meow', 'ownership_rights': 'original_owner', 'isrc': '', 'recording_country_id': 1, 'localizations': [], 'meta_language_code': 'ZUN', 'explicit': 'N', 'preview_start_time': None, 'writers': [track_writer_fixture_with_artist_info_id], 'artists': [], 'upc': 12345, 'original_rights_holder_country_id': 1 } @pytest.fixture def create_artist_info_success_response(release_artist_fixture): """Mock successful response from create_artist_info.""" return MagicMock( spec=requests.models.Response, status_code=201, json=lambda: release_artist_fixture) @pytest.fixture def get_track_info_success_response(get_track_info_fixture): """Mock successful response from get_track_info.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: get_track_info_fixture) @pytest.fixture def update_track_contributor_success_response(track_artist_fixture): """Mock successful response from update_track_contributor.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: track_artist_fixture ) @pytest.fixture def filter_artists_info_fixture(artist_name): """filter_artists_info return fixture.""" return { 'items': [ { 'name': artist_name, 'id': 1, 'artist_type': 'artist', }, { 'name': artist_name, 'id': 2, 'artist_type': 'artist', } ] } @pytest.fixture def filter_artists_info_success_response(filter_artists_info_fixture): """Mock successful response for filter_artists_info.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: filter_artists_info_fixture) @pytest.fixture def vendor_id(): """Vendor ID fixture.""" return 23787 @pytest.fixture def product_info_fixture(product_name, product_id, vendor_id): """get_product_info data fixture.""" return { 'context_type': 'digital', 'product_name': product_name, 'upc': 191773660765, 'distribution_format_id': 1, 'subaccount_id': 0, 'status': 'active', 'product_id': product_id, 'release_date': '2017-09-11', 'project_id': 3772799, 'product_type_id': 1, 'vendor_id': vendor_id, 'deletions': 'N' } @pytest.fixture def product_info_fixture_with_subaccount_id( product_name, product_id, vendor_id): """get_product_info data fixture with subaccount ID.""" return { 'context_type': 'digital', 'product_name': product_name, 'upc': 191773660765, 'distribution_format_id': 1, 'subaccount_id': 1, 'status': 'active', 'product_id': product_id, 'release_date': '2017-09-11', 'project_id': 3772799, 'product_type_id': 1, 'vendor_id': vendor_id, 'deletions': 'N' } @pytest.fixture def product_info_success_response(product_info_fixture): """Mock successful response from get_product_info.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: product_info_fixture) @pytest.fixture def ows_error_response(): """Mock error response from a microservice.""" return MagicMock(spec=requests.models.Response, status_code=500) @pytest.fixture def digital_product_fixture(release_artist_fixture, product_name, product_id): """Digital product fixture.""" return { 'artist_id': 7923, 'c_line': '2016 Awesome Records', 'description': 'The greatest product ever, ever', 'distribution_format_id': 1, 'format': 'Single', 'genre_id': 13, 'imprint': 'Awesome Records', 'manufacturer_upc': '123456789012', 'meta_language': 'SUX', 'preorder_date': '2016-4-28', 'previewable': 'yes', 'product_artists': [release_artist_fixture], 'product_code': 'AProduct123', 'product_id': product_id, 'product_name': product_name, 'product_type_id': 1, 'project_id': 12345, 'release_date': '2016-05-31', 'release_status': 'label_processing', 'sale_start_date': '2016-05-31', 'special_instructions': 'I open at the close.', 'subgenre_id': None, 'upc': '123456789012', 'vendor_catalog_number': 'DigProdNumber1', 'version': 'Delux' } @pytest.fixture def digital_product_info_success_response(digital_product_fixture): """Mock successful response from get_digital_product_info.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: digital_product_fixture) @pytest.fixture def ows_not_found_response(): """Mock not found response from a microservice.""" return MagicMock(spec=requests.models.Response, status_code=404) @pytest.fixture def get_features_success_response(features): """Mock successful response from get_features.""" return MagicMock( json=lambda: features, spec=requests.models.Response, status_code=200 ) @pytest.fixture def get_features_authorization_error(): """Mock incomplete grass headers response.""" return MagicMock(spec=requests.models.Response, status_code=400)