"""Shared test fixtures.""" import base64 from copy import copy import json from unittest.mock import MagicMock import pytest import requests TEST_PRODUCT_NAME = 'The Whitefriar Street Christmas Service' TEST_PROJECT_ID = 3878967 TEST_PROJECT_CODE = 'BEES555555' TEST_PROJECT_NAME = 'Mambos And Cha Cha Chas' TEST_PROJECT_DESCRIPTION = 'Project description ...' TEST_RELEASE_ID = 2104178 TEST_RELEASE_STATUS = 'label_processing' TEST_PRODUCT_CODE = 'CD111222' TEST_UPC = 191773660765 TEST_VENDOR_ID = 23787 TEST_SUBACCOUNT_ID = 0 TEST_TRACK_ID = 26265357 TEST_ARTIST_ID = 81151686 TEST_ARTIST = 'Paul Harrington' TEST_ISRC = 'QM6P41733255' TEST_SUBACCOUNT = 3 TEST_SUBACCOUNT_NAME = 'Test Subaccount' TEST_VENDOR_NAME = 'Test Vendor' TEST_VEND_CONTACT_1 = 1 TEST_VEND_CONTACT_2 = 2 TEST_CONTACT_1 = 1 TEST_EXCLUDED_PRODUCT_ID = 2685840 TEST_EXCLUDED_PROJECT_ID = 4074976 @pytest.fixture def product_name(): """Test product name.""" return TEST_PRODUCT_NAME @pytest.fixture def release_id(): """Test release id.""" return TEST_RELEASE_ID @pytest.fixture def track_id(): """Test track id.""" return TEST_TRACK_ID @pytest.fixture def artist_name(): """Test artist name.""" return TEST_ARTIST @pytest.fixture def isrc(): """Test artist name.""" return TEST_ISRC @pytest.fixture def track_db_row(isrc, track_id, release_id): """Row from art_relations.track.""" return { 'track_name': 'Joy to the World EQ MSTR\u0014\u0019', 'upc': 191773660765, 'cd': 1, 'track_id': 6, 'orchdmclip': None, 'sample': 'N', 'dmclips': None, 'isrc': isrc, 'id': track_id, 'length_minute': 1, 'length_seconds': 56, 'writer': None, 'credit': 'orig_comp', 'mechanical': 'no', 'publisher': None, 'publish_company': None, 'dpd_license': 'no', 'explicit_lyrics': 'N', 'version': None, 'purchasable': 'Y', 'download_price': None, 'p_line': '2017 Beaumex', 'hidden': None, 'offer_type': 'all', 'dig_distribution_type': 'digital_mobile', 'third_party_publisher': 'N', 'royalty_collection': 'Y', 'publishing_admin': 'N', 'sync_admin': 'Y', 'additional_id': None, 'track_type': 'music', 'mp3_url': None, 'stereo_or_mono': None, 'bonus': 'N', 'recommended': 'N', 'youtube_matches': 'Monetize', 'youtube_uploads': None, 'preorder_only': 'N', 'original_file_name': None, 'release_id': release_id, 'last_updated': '2017-08-28T11:00:22.000000', 'meta_language': 'ENG', 'preview_start_time': None, 'closed_caption_exists': None, 'closed_caption_reason_id': None, 'vendor_track_identifier': None, 'recording_country': 90, 'recording_year': None, 'original_track_id': None, 'us_publishing_obligation': 'PublicDomain' } @pytest.fixture def track_maxwells_event_fixture(track_db_row): """Track row event from Maxwell's Daemon.""" row = copy(track_db_row) row['_metadata'] = { 'timestamp': 1503918022, 'log_file': 'mysql-bin.004429', 'log_position': 531113031, 'table': 'track', 'schema': 'art_relations', 'event_type': 'track', 'schema_url': 'schema?id=2ed58075-dfc9-409c-9587-5ab7738ca48f&' 'schema_object=art_relations.track', '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_track_event_fixture(track_db_row): """Maxwell's Daemon track event converted to internal format.""" return { 'data': track_db_row, 'table': 'track', 'type': 'insert' } def kinesis_event_fixture(fixture): """Mock a Kinesis event.""" return { 'Records': [ { 'kinesis': { 'data': base64.b64encode( json.dumps(fixture).encode('utf8')) } } ] } @pytest.fixture def track_kinesis_event_fixture(converted_track_event_fixture): """Track Kinesis event fixture.""" return kinesis_event_fixture(converted_track_event_fixture) @pytest.fixture def kinesis_event_incompatible_fixture(): """Test event received from Kinesis in incompatible format.""" return { 'Records': [ { 'kinesis': { 'data': base64.b64encode( json.dumps({'wrong': 'data'}).encode('utf8')) } } ] } @pytest.fixture def release_info_fixture(): """Test data received from ows-product.""" return { 'context_type': 'digital', 'product_name': TEST_PRODUCT_NAME, 'upc': TEST_UPC, 'distribution_format_id': 1, 'subaccount_id': TEST_SUBACCOUNT_ID, 'status': TEST_RELEASE_STATUS, 'product_id': TEST_RELEASE_ID, 'release_date': '2017-09-11', 'project_id': 3772799, 'product_type_id': 1, 'vendor_id': TEST_VENDOR_ID, 'deletions': 'N' } @pytest.fixture def release_info_success_response(release_info_fixture): """Mock successful response from ows-product.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: release_info_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 ows_error_response(): """Mock error response from a microservice.""" return MagicMock(spec=requests.models.Response, status_code=500) @pytest.fixture def get_release_info_fixture(): """Mock result of get_release_info() function.""" return { 'release_name': TEST_PRODUCT_NAME, 'release_status': TEST_RELEASE_STATUS, 'upc': TEST_UPC, 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': TEST_SUBACCOUNT_ID, 'deletions': 'N' } @pytest.fixture def get_release_info_not_found_fixture(): """Mock not found result of get_release_info function.""" return { 'release_name': '', 'release_status': '', 'upc': 0, 'vendor_id': 0, 'subaccount_id': 0, 'deletions': 'N' } @pytest.fixture def product_document_fixture(): """Test data received from ows-product.""" return { 'display': 'Y', 'artist_url': '', 'vendor_status': 'signed', 'c_line': '2012 One Media Publishing', 'project_id': TEST_PROJECT_ID, 'release_status': 'in_content', 'vendor_owner': 'SC', 'product_type': 'Music', 'artist_id': TEST_ARTIST_ID, 'artist_myspace_url': '', 'track_type': [ 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music', 'music' ], 'subgenre': 'Classical', 'product_type_id': 1, 'vendor_catalog_number': 'OMPCB64D0013', 'configuration': 'Digital', 'label': 'One Media IP', 'product_code': TEST_PRODUCT_CODE, 'release_date': '2012-08-12', 'genre': 'Classical', 'release_name': TEST_PRODUCT_NAME, 'featured': 'N', 'episode': None, 'format': 'Full Length', 'release_year': 2012, 'subaccount_id': None, 'track_list': [ 'La Jolie Fille De Perth (The Fair Maid of Perth) Suite I. Prelude', # noqa 'La Jolie Fille De Perth (The Fair Maid of Perth) Suite II. Serenade No.1', # noqa 'La Jolie Fille De Perth (The Fair Maid of Perth) Suite III. March', # noqa 'La Jolie Fille De Perth (The Fair Maid of Perth) Suite IV. Serenade No.2', # noqa 'La Jolie Fille De Perth (The Fair Maid of Perth) Suite V. Danse Bohemienne', # noqa 'Carmen Suite No.1 Prelude. Allegro Giocoso', "Carmen Suite No 1 Les Dragons D'alcala(Prelude to Act Ii)", 'Carmen Suite No 1 Intermezzo (Prelude to Act Iii) Andantino Quasi Allegretto',# noqa 'Carmen Suite No 1 Aragonaise (Prelude Ot Act Iv) Andante Moderato', # noqa "L' Arlesienne Suite No.1 Op. 23: III.Adagietto", "L' Arlesienne Suite No.1 Op. 23: IV. Carillon", "L' Arlesienne Suite No.1 Op. 23: II.Minuet", "L' Arlesienne Suite No.1 Op. 23: I.Prelude", "L' Arlesienne Suite No.2 Op. 23: IV.Farandole", "L' Arlesienne Suite No.2 Op. 23: II.Intermezzo", "L' Arlesienne Suite No.2 Op. 23: III.Minuet", "L' Arlesienne Suite No.2 Op. 23: I.Pastorale", 'Roma: Carnaval À Rome', 'Patrie Op. 19: Overture', 'Carmen Suite No.2:' ], 'upc': TEST_UPC, 'artist_name': 'Various Artists', 'display_upc': f'{TEST_UPC}', 'sale_start_date': '2012-08-12', 'vendor_id': 10693, 'imprint': 'OMP Classics', 'release_id': TEST_RELEASE_ID, 'product_configuration': 'Digital Audio', 'release_month': 8, 'artist_description': '', 'delivered_version': 'Live at Wembley', 'isrc_list': [ 'GBQRF1107530', 'GBQRF1107531', 'GBQRF1107532', 'GBQRF1107533', 'GBQRF1107534', 'GBQRF1107642', 'GBQRF1107644', 'GBQRF1107645', 'GBQRF1107646', 'GBQRF1107650', 'GBQRF1107653', 'GBQRF1107648', 'GBQRF1107647', 'GBQRF1107660', 'GBQRF1107657', 'GBQRF1107659', 'GBQRF1107656', 'GBQRF1107811', 'GBQRF1107817', 'GBQRF1108100', 'GBQRF1108099' ], 'deletions': 'N', 'project_code': TEST_PROJECT_CODE, 'project_name': TEST_PROJECT_NAME } @pytest.fixture def product_kinesis_event_fixture(converted_product_event_fixture): """Track Kinesis event fixture.""" return kinesis_event_fixture(converted_product_event_fixture) @pytest.fixture def product_kinesis_update_event_fixture(converted_product_update_event_fixture): """Track Kinesis update event fixture.""" return kinesis_event_fixture(converted_product_update_event_fixture) @pytest.fixture def converted_release_correction_event_fixture(): """Maxwell's Daemon releases event converted to internal format.""" return { 'data': {'release_id': TEST_RELEASE_ID}, 'table': 'release_correction', 'type': 'insert' } @pytest.fixture def release_correction_kinesis_event_fixture( converted_release_correction_event_fixture): """Maxwell's Daemon release_correction event.""" return kinesis_event_fixture(converted_release_correction_event_fixture) @pytest.fixture def converted_release_approval_queue_event_fixture(): """Maxwell's Daemon releases event converted to internal format.""" return { 'data': {'release_id': TEST_RELEASE_ID}, 'table': 'release_approval_queue', 'type': 'insert' } @pytest.fixture def release_approval_queue_kinesis_event_fixture( converted_release_approval_queue_event_fixture): """Maxwell's Daemon release_approval_queue event.""" return kinesis_event_fixture(converted_release_approval_queue_event_fixture) @pytest.fixture def product_cloudsearch_document(product_document_fixture): """Product Cloudsearch document ready for upload.""" return { 'type': 'add', 'id': f'rel{TEST_RELEASE_ID}', 'fields': product_document_fixture } @pytest.fixture def converted_product_event_fixture(product_db_row): """Maxwell's Daemon releases event converted to internal format.""" product_db_row['release_status'] = 'in_content' return { 'data': product_db_row, 'old': {'release_status': 'transfer_to_content'}, 'table': 'releases', 'type': 'insert' } @pytest.fixture def converted_product_update_event_fixture(product_db_row): """Maxwell's Daemon releases update event converted to internal format.""" return { 'data': product_db_row, 'table': 'releases', 'type': 'update' } @pytest.fixture def product_db_row(): """Row from art_relations.releases.""" return { 'release_id': TEST_RELEASE_ID, 'last_updated': '2018-03-11 16:32:44', 'upc': TEST_UPC, 'display_upc': f'{TEST_UPC}', 'artist_id': TEST_ARTIST_ID, 'subaccount_id': None, 'vendor_release_identifier': None, 'release_name': TEST_PRODUCT_NAME, 'label': 'Bless Music Group', 'description': None, 'release_date': '2018-03-12', 'listprice': None, 'sellprice': None, 'display': 'Y', 'deletions': 'N', 'distribution': 'digital', 'applfees': None, 'referral_id': None, 'date_added_REMOVE': None, 'genre_id': 19, 'format': 'Full Length', 'distribution_format_id': 1, 'orig_release_year': None, 'promocode': None, 'c_line': '2018 Bless', 'manufacturer_upc': None, 'album_download': 'Y', 'download_price': None, 'priority': 3, 'territory': None, 'sale_start_date': '2018-03-12', 'vod_start_date': None, 'original_release_date': None, 'vendor_catalog_number': 15, 'language_id': None, 'promobox_no': None, 'additional_id': None, 'dracatalog': None, 'channel_id': None, 'product_type_id': 1, 'trackdown_black_list': 'N', 'not_for_distribution': 'N', 'europe_public_domain': None, 'karaoke': None, 'unknown_artist': None, 'new_release': None, 'product_format': None, 'product_code': None, 'special_instructions': None, 'promos_number': None, 'promo_upc': None, 'sync_only': 'N', 'country_of_origin': None, 'short_synopsis': None, 'keywords': None, 'production_co': None, 'preorder_date': None, 'amd_id': None, 'wholesale_price_tier': None, 'season': None, 'episode': None, 'production_number': None, 'network': None, 'genre_note': None, 'physical_release_date': None, 'theatrical_release_date': None, 'original_digital_release_date': None, 'est': None, 'vod': None, 'rsd_comment': None, 'int_mkt_manager': None, 'tms_id': None, 'brand': None, 'digital_only': 'N', 'product_subtype_id': None, 'version': None, 'delivered_version': None, 'ingestion_completed': None, 'release_status': 'transfer_to_content', 'meta_language': 'SPA', 'itunes_previewable': None, 'subtitle_language_id': None, 'compilation': 'N', 'project_id': 3882049 } @pytest.fixture def converted_project_event_fixture(project_db_row): """Maxwell's Daemon project event converted to internal format.""" return { 'data': project_db_row, 'table': 'project', 'type': 'insert' } @pytest.fixture def project_kinesis_event_fixture(converted_project_event_fixture): """Project Kinesis event fixture.""" return kinesis_event_fixture(converted_project_event_fixture) @pytest.fixture def converted_artist_event_fixture(artist_db_row): """Maxwell's Daemon artist event converted to internal format.""" return { 'data': artist_db_row, 'table': 'artist_info', 'type': 'insert' } @pytest.fixture def artist_kinesis_event_fixture(converted_artist_event_fixture): """Artist Kinesis event fixture.""" return kinesis_event_fixture(converted_artist_event_fixture) @pytest.fixture def track_info_fixture(): """Mock track info received from ows-track.""" return { 'tuid': 26265357, 'track_name': 'Joy to the World', 'volume_number': 1, 'meta_language_code': 'ENG', 'version': '', 'localizations': [], 'writers': [ { 'type': 'writer', 'track_writer_id': 52703447, 'name': 'Public Domain' } ], 'product_id': 2104178, 'explicit': 'N', 'track_number': 8, 'artists': [ { 'type': 'performer', 'track_artist_id': TEST_ARTIST_ID, 'name': TEST_ARTIST }, { 'type': 'featuring', 'track_artist_id': 81151700, 'name': 'The Whitefriar Street Church Choir' } ], 'isrc': 'QM6P41735154', 'recording_country_id': 90, 'upc': 191773660765, 'p_info': '2014 Beaumex', 'original_rights_holder_country_id': 90, 'ownership_rights': 'owner', 'preview_start_time': None } @pytest.fixture def second_track_info_fixture(): """Mock second track info received from ows-track.""" return { 'tuid': 26265358, 'track_name': 'Second Joy to the World', 'volume_number': 1, 'meta_language_code': 'ENG', 'version': '', 'localizations': [], 'writers': [ { 'type': 'writer', 'track_writer_id': 52703447, 'name': 'Public Domain' } ], 'product_id': 2104178, 'explicit': 'N', 'track_number': 8, 'artists': [ { 'type': 'performer', 'track_artist_id': TEST_ARTIST_ID, 'name': TEST_ARTIST }, { 'type': 'featuring', 'track_artist_id': 81151701, 'name': 'Street Choir' } ], 'isrc': 'QM6P41735155', 'recording_country_id': 90, 'upc': 191773660765, 'p_info': '2014 Beaumex', 'original_rights_holder_country_id': 90, 'ownership_rights': 'owner', 'preview_start_time': None } @pytest.fixture def track_info_success_response(track_info_fixture): """Mock success response from ows-track microservice.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: track_info_fixture) @pytest.fixture def get_track_info_fixture(): """Mock result of get_track_info function.""" return { 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST } @pytest.fixture def get_track_info_not_found_fixture(): """Mock not found result of get_track_info function.""" return { 'artist_id': 0, 'artist_name': '' } @pytest.fixture def tracks_by_product_id_success_response(track_info_fixture, second_track_info_fixture): """Mock success response from ows-track microservice.""" return MagicMock( spec=requests.models.Response, status_code=200, json=lambda: { 'items': [track_info_fixture, second_track_info_fixture] }) @pytest.fixture def get_tracks_by_product_id_fixture(track_info_fixture, second_track_info_fixture): """Tracks data for product id.""" track_info_fixture['artist_id'] = TEST_ARTIST_ID track_info_fixture['artist_name'] = TEST_ARTIST second_track_info_fixture['artist_id'] = TEST_ARTIST_ID second_track_info_fixture['artist_name'] = TEST_ARTIST return [track_info_fixture, second_track_info_fixture] @pytest.fixture def track_cloudsearch_document(track_maxwells_event_fixture): """Track Cloudsearch document ready for upload.""" return { 'type': 'add', 'id': f'track{TEST_TRACK_ID}', 'fields': { 'track_unique_id': TEST_TRACK_ID, 'isrc': TEST_ISRC, 'release_id': TEST_RELEASE_ID, 'track_name': 'Joy to the World EQ MSTR', 'version': '', 'cd': track_maxwells_event_fixture['cd'], 'track_id': track_maxwells_event_fixture['track_id'], 'track_type': track_maxwells_event_fixture['track_type'], 'original_file_name': '', 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST, 'release_name': TEST_PRODUCT_NAME, 'release_status': TEST_RELEASE_STATUS, 'upc': TEST_UPC, 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': TEST_SUBACCOUNT_ID, 'deletions': 'N' } } @pytest.fixture def tracks_for_product_cloudsearch_document(): """Test tracks data for product id received from ows-tracks.""" return [ { 'type': 'add', 'id': 'track26265357', 'fields': { 'track_unique_id': 26265357, 'release_id': TEST_RELEASE_ID, 'track_name': 'Joy to the World', 'upc': TEST_UPC, 'isrc': 'QM6P41735154', 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST, 'release_name': TEST_PRODUCT_NAME, 'release_status': 'in_content', 'vendor_id': TEST_VENDOR_ID, 'version': '', 'subaccount_id': TEST_SUBACCOUNT_ID, 'deletions': 'N' } }, { 'type': 'add', 'id': 'track26265358', 'fields': { 'track_unique_id': 26265358, 'release_id': TEST_RELEASE_ID, 'track_name': 'Second Joy to the World', 'upc': TEST_UPC, 'isrc': 'QM6P41735155', 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST, 'release_name': TEST_PRODUCT_NAME, 'release_status': 'in_content', 'version': '', 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': TEST_SUBACCOUNT_ID, 'deletions': 'N' } } ] @pytest.fixture def project_document_fixture(): """Test data received from ows-project-manager.""" return { 'project_id': TEST_PROJECT_ID, 'project_code': TEST_PROJECT_CODE, 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': TEST_SUBACCOUNT_ID, 'project_name': TEST_PROJECT_NAME, 'created_date_utc': '2018-03-07 23:53:14.893249', 'updated_date_utc': '2018-03-07 23:53:14.893249', 'correlation_id': '123', 'description': TEST_PROJECT_DESCRIPTION, 'artist_id': TEST_ARTIST_ID, 'name': TEST_ARTIST, 'artist_description': 'The best honky tonky', 'artist_url': 'http://www.billy.com/' } @pytest.fixture def tracks_by_product_id_fixture(): """Test tracks data by product id received from ows-tracks.""" return [ { 'tuid': 26265357, 'track_name': 'Joy to the World', 'volume_number': 1, 'meta_language_code': 'ENG', 'product_id': TEST_RELEASE_ID, 'explicit': 'N', 'track_number': 1, 'recording_country_id': 90, 'upc': 191773660765, 'p_info': '2014 Beaumex', 'original_rights_holder_country_id': 90, 'ownership_rights': 'owner', 'preview_start_time': None, 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST }, { 'tuid': 26265358, 'track_name': 'Joy to the World 2', 'volume_number': 1, 'meta_language_code': 'ENG', 'product_id': TEST_RELEASE_ID, 'explicit': 'N', 'track_number': 2, 'recording_country_id': 90, 'upc': 191773660766, 'p_info': '2014 Beaumex', 'original_rights_holder_country_id': 90, 'ownership_rights': 'owner', 'preview_start_time': None, 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST }] @pytest.fixture def artist_document_fixture(): """Test data received from ows-artist.""" return { 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST, 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': ['123', '456'] } @pytest.fixture def project_cloudsearch_document(project_document_fixture): """Project Cloudsearch document ready for upload.""" return { 'type': 'add', 'id': f'proj{TEST_PROJECT_ID}', 'fields': project_document_fixture } @pytest.fixture def artist_cloudsearch_document(artist_document_fixture): """Artist Cloudsearch document ready for upload.""" return { 'type': 'add', 'id': f'art{TEST_ARTIST_ID}', 'fields': artist_document_fixture } @pytest.fixture def project_db_row(): """Row from art_relations.project.""" return { 'project_id': TEST_PROJECT_ID, 'project_code': TEST_PROJECT_CODE, 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': TEST_SUBACCOUNT_ID, 'project_name': TEST_PROJECT_NAME, 'created_date_utc': '2018-03-07 23:53:14.893249', 'updated_date_utc': '2018-03-07 23:53:14.893249', 'correlation_id': 'beef4980-2262-11e8-9b46-0242ac110002.1', 'artist_id': TEST_ARTIST_ID, 'description': TEST_PROJECT_DESCRIPTION } @pytest.fixture def artist_db_row(): """Row from art_relations.artist_info.""" return { 'artist_id': TEST_ARTIST_ID, 'artist_name': TEST_ARTIST, 'vendor_id': TEST_VENDOR_ID, 'subaccount_id': ['123', '456'] } @pytest.fixture def subaccount_kinesis_event_fixture(converted_subaccount_event_fixture): """Subaccount Kinesis event fixture.""" return kinesis_event_fixture(converted_subaccount_event_fixture) @pytest.fixture def subaccount_cloudsearch_document(subaccount_document_fixture): """Subaccount Cloudsearch document ready for upload.""" return { 'type': 'add', 'id': f'sub{TEST_SUBACCOUNT}', 'fields': subaccount_document_fixture } @pytest.fixture def subaccount_document_fixture(): """Test data received from ows-account.""" return { 'label_id': TEST_SUBACCOUNT, 'label_name': TEST_SUBACCOUNT_NAME, 'is_active': 1, 'is_owned': 'No', 'label_owner': 'odd', 'label_status': 'signed', 'label_type': 'Subaccount', 'label_country': 'test', 'parent_label': TEST_VENDOR_NAME, 'client_manager': 'Tester', 'parent_label_id': TEST_VENDOR_ID } @pytest.fixture def converted_subaccount_event_fixture(subaccount_db_row): """Maxwell's Daemon subaccount event converted to internal format.""" return { 'data': subaccount_db_row, 'table': 'subaccount', 'type': 'insert' } @pytest.fixture def subaccount_db_row(): """Row from art_relations.subaccount.""" return { 'subaccount_id': TEST_SUBACCOUNT, 'vendor_id': TEST_VENDOR_ID, 'subaccount_name': TEST_SUBACCOUNT_NAME, 'genre_id': 1, 'website_url': 'test.com', 'myspace_url': 'test.com', 'city': 'test', 'state_province': 1, 'other_state': 'test', 'country_id': 1, 'description': 'test', 'commission_override': 0.5, 'date_deleted': None, 'date_created': '2018-12-20 00:00:00', 'last_updated': '2018-12-20 00:00:00', 'subaccount_split_type': 'Net' } @pytest.fixture def vendor_kinesis_event_fixture(converted_vendor_event_fixture): """Vendor Kinesis event fixture.""" return kinesis_event_fixture(converted_vendor_event_fixture) @pytest.fixture def vendor_cloudsearch_document(vendor_document_fixture): """Vendor Cloudsearch document ready for upload.""" return { 'type': 'add', 'id': f'ven{TEST_VENDOR_ID}', 'fields': vendor_document_fixture } @pytest.fixture def vendor_document_fixture(): """Test data received from ows-account.""" return { 'label_type': 'D3', 'is_owned': 'No', 'label_id': TEST_VENDOR_ID, 'label_country': 'USA', 'label_owner': 'Test', 'client_manager': 'Tester', 'label_contact_name': 'Tester', 'label_status': 'signed', 'label_contact_id': 1234, 'label_contact_login': 'test@test.org', 'label_name': TEST_VENDOR_NAME } @pytest.fixture def converted_vendor_event_fixture(vendor_db_row): """Maxwell's Daemon vendor event converted to internal format.""" return { 'data': vendor_db_row, 'table': 'vendor', 'type': 'insert' } @pytest.fixture def vendor_db_row(): """Row from art_relations.vendor.""" return { 'vendor_id': TEST_VENDOR_ID, 'is_distributor': 'Y', 'name': 'test', 'company': TEST_VENDOR_NAME, 'newsletter': 'Y', 'login': '', 'old_passwords': '', 'bademail': 'N', 'last_update': '2018-12-20 00:00:00', 'passwords': '', 'is_login_null': 'no', 'referral': '', 'join_vendor_id': '', 'owner': 'Test', 'priority': 1, 'region': 0, 'primary_genre': 1, 'est_total_releases': 0, 'est_total_tracks': 0, 'date_created': '2018-12-20 00:00:00', 'overall_priority': None, 'assigned_to': 1, 'status': 'signed', 'website': '', 'ca_rep': None, 'tax_form_received': 'N', 'w8_tax_form_date': '00:00:00', 'date_signed': '', 'payment_type': 'check', 'wire_info': 'test', 'wel_email_sender': None, 'wel_email_send_date': None, 'label_summary': 'test', 'myspace_url': None, 'additional_id': 123, 'monthly_accounting': 'N', 'original_owner': None, 'show_release_builder': 'Y', 'recurring_payment_threshold': 0.000000, 'encrypted_tin': '', 'checks': '', 'tax_name': '', 'tax_id_type': '', 'tax_id_country': 0, 'encrypted_foreign_tin': '', 'country': 1, 'number_format': 'us', 'language': 'en', 'token': None, 'allow_orchard_credit': 'N', 'api_vendor_id': None, 'contact_email': None, 'label_identifier': 'D3', 'is_owned': 'No', 'last_modified_by': 123, 'support_contact_email': 'test@test.org', 'first_statement_period': 1 } @pytest.fixture def subaccount_id(): """Test subaccount id.""" return TEST_SUBACCOUNT @pytest.fixture def vendor_id(): """Test vendor id.""" return TEST_VENDOR_ID @pytest.fixture def user_document_fixture(): """Test data received from ows-users.""" return [ { 'user_id': TEST_VEND_CONTACT_1, 'subaccount_id': TEST_SUBACCOUNT, 'is_active': 1, 'permissions': 'Catalog,Analytics', 'subaccount': TEST_SUBACCOUNT_NAME, 'vendor_id': TEST_VENDOR_ID, 'master': 'N', 'contact_first_name': 'Tester', 'contact_last_name': 'Tester', 'contact_email': 'tester@test.com' }, { 'user_id': TEST_VEND_CONTACT_2, 'subaccount_id': TEST_SUBACCOUNT, 'is_active': 1, 'permissions': 'Administrator', 'subaccount': TEST_SUBACCOUNT_NAME, 'vendor_id': TEST_VENDOR_ID, 'master': 'N', 'contact_first_name': 'New', 'contact_last_name': 'Tester', 'contact_email': 'newtester@test.com' } ] @pytest.fixture def user_cloudsearch_document_for_subaccount(user_document_fixture): """User Cloudsearch document ready for uploading multiple documents.""" return [ { 'type': 'add', 'id': f'user{TEST_VEND_CONTACT_1}', 'fields': user_document_fixture[0] }, { 'type': 'add', 'id': f'user{TEST_VEND_CONTACT_2}', 'fields': user_document_fixture[1] } ] @pytest.fixture def converted_vend_contact_event_fixture(vend_contact_db_row): """Maxwell's Daemon vend_contact event converted to internal format.""" return { 'data': vend_contact_db_row, 'table': 'vend_contact', 'type': 'insert' } @pytest.fixture def vend_contact_db_row(): """Row from art_relations.vend_contact.""" return { 'vendor_id': TEST_VENDOR_ID, 'contact_id': TEST_CONTACT_1, 'master': 'N', 'id': TEST_VEND_CONTACT_1, 'login': 'test', 'old_passwords': None, 'passwords': 'test', 'language': 'en1', 'number_format': 'us', 'active': 'Y', 'password_request_key': 'test', 'password_reset_datetime': '2019-04-01 00:00:00', 'subaccount_id': TEST_SUBACCOUNT, 'auth0_user_id': None, 'auth0_migration_date': None, 'auth0_primary': None } @pytest.fixture def user_cloudsearch_document(user_document_fixture): """User Cloudsearch document ready for uploading single document.""" return [ { 'type': 'add', 'id': f'user{TEST_VEND_CONTACT_1}', 'fields': user_document_fixture[0] } ] @pytest.fixture def converted_contact_event_fixture(contact_db_row): """Maxwell's Daemon contact event converted to internal format.""" return { 'data': contact_db_row, 'table': 'contact', 'type': 'insert' } @pytest.fixture def contact_db_row(): """Row from art_relations.contact.""" return { 'contact_first_name': 'Tester', 'contact_middle_name': 'Tester', 'contact_last_name': 'Tester', 'contact_email': 'tester@test.com', 'contact_affiliation': '', 'alt_email': '', 'contact_comment': None, 'contact_id': TEST_CONTACT_1, 'contact_title': '', 'affiliation_id': None, 'address_street': 'test', 'address_city': 'test', 'address_zip': 9999, 'address_state': 'test', 'contact_cell': '', 'contact_fax': '', 'contact_phone': 213213, 'contact_phone_2': '', 'checks_remove': None, 'company': TEST_VENDOR_NAME, 'instrument': '', 'address2': 'test', 'country': None, 'orchard_country': 1, 'address_other_state': 'test', 'contact_type': 'primary', 'send_option': '', 'address_last_updated': '2019-04-01 00:00:00', 'last_modified_by': None, 'user_type': None, 'requested_login_email': None } @pytest.fixture def converted_role_event_fixture(vend_contact_roles_db_row): """Maxwell's Daemon vend_contact_roles event converted to internal format.""" return { 'data': vend_contact_roles_db_row, 'table': 'vend_contact_roles', 'type': 'insert' } @pytest.fixture def vend_contact_roles_db_row(): """Row from art_relations.vend_contact_roles.""" return { 'id': 1, 'role_id': 4, 'vend_contact_id': TEST_VEND_CONTACT_1 } @pytest.fixture def vend_contact_id(): """Test vend_contact id.""" return TEST_VEND_CONTACT_1 @pytest.fixture def contact_id(): """Test contact id.""" return TEST_CONTACT_1 @pytest.fixture def user_kinesis_event_fixture(converted_vend_contact_event_fixture): """User Kinesis event fixture.""" return kinesis_event_fixture(converted_vend_contact_event_fixture) @pytest.fixture def converted_delete_row_fixture(): """Test delete event.""" return { 'type': 'delete', 'id': f'rel{TEST_EXCLUDED_PRODUCT_ID}', } @pytest.fixture def product_id(): """Test product Id.""" return TEST_EXCLUDED_PRODUCT_ID @pytest.fixture def converted_project_delete_row_fixture(): """Test delete project event.""" return { 'type': 'delete', 'id': f'proj{TEST_EXCLUDED_PROJECT_ID}', } @pytest.fixture def project_id(): """Test project Id.""" return TEST_EXCLUDED_PROJECT_ID @pytest.fixture def converted_track_delete_row_fixture(): """Test delete track event.""" return { 'type': 'delete', 'id': f'track{TEST_TRACK_ID}', }