"""conftest. This file gets picked up when running py.test tests: http://pytest.org/latest/writing_plugins.html#conftest """ import pytest import pandas as pd @pytest.fixture def mock_get_all_active_contract_mechanical_deductions_response(): """Return a list of dicts representing abacus active contract with mechanical deductions.""" return [ { 'account_id': 1, 'contract_id': 1, 'term_type': 'product', 'attachments': [ '135789012346', ], 'mechanical_type': ['digital', 'physical'], }, { 'account_id': 1, 'contract_id': 2, 'term_type': 'label', 'attachments': [ '1', ], 'mechanical_type': ['digital', 'physical'], }, { 'account_id': 1, 'contract_id': 3, 'term_type': 'track', 'attachments': [ 'USGHI7654321', ], 'mechanical_type': ['digital', 'physical'], }, { 'account_id': 6, 'contract_id': 6, 'term_type': 'product', 'attachments': ['000000000000', '11111111111'], 'mechanical_type': ['digital', 'physical'], } ] @pytest.fixture def mock_get_hfa_eligible_tracks_response(): """Return a list of dicts representing HFA eligible digital/physical release query results.""" return [ { 'track_id': 101, 'track_isrc': 'USABC1234567', 'upc': '123456789012', 'release_id': 10, 'vendor_id': 3, 'hfa_configuration_code': 'SP', 'trans_type': 'digital', }, { 'track_id': 102, 'track_isrc': 'USDEF7654321', 'upc': '987654321098', 'release_id': 20, 'vendor_id': 1, 'hfa_configuration_code': 'CS', 'trans_type': 'physical', }, { 'track_id': 103, 'track_isrc': 'USGHI7654321', 'upc': '135789012346', 'release_id': 30, 'vendor_id': 43, 'hfa_configuration_code': 'RT', 'trans_type': 'digital' } ] @pytest.fixture def mock_get_carveouts_row_1(): """Return a list of dicts representing HFA eligible digital/physical release query results.""" return { 'account': { 'service': [ { 'service_id': 1, 'service_name': 'test', 'distribution_types': [ 1 ] } ], 'service_country': [], 'country': [ 'RU' ], 'new_service_opt_outs': [] }, 'subaccount': { 'service': [], 'service_country': [], 'country': [] }, 'product': { 'service': [ { 'service_id': 4, 'service_name': 'test2', 'distribution_types': [ 1 ] } ], 'service_country': [], 'country': [ 'AG', 'AI', 'AN', 'AW' ], 'new_service_opt_outs': [] } } @pytest.fixture def mock_get_carveouts_row_2(): """Return a list of dicts representing HFA eligible digital/physical release query results.""" return { 'account': { 'service': [ { 'service_id': 111, 'service_name': 'test', 'distribution_types': [1] }, {'service_id': 222, 'service_name': 'test2', 'distribution_types': [1]}, { 'service_id': 333, 'service_name': 'YouTube AT (SL Use Only)', 'distribution_types': [1] } ], 'service_country': [], 'country': ['RU'], 'new_service_opt_outs': [] }, 'subaccount': {'service': [], 'service_country': [], 'country': []}, 'product': { 'service': [], 'service_country': [], 'country': [], 'new_service_opt_outs': [] } } @pytest.fixture def mock_hfa_eligible_digital_physical_release_df( mock_hfa_eligible_digital_physical_release_rows ): """Return a HFA eligible digital/physical release DataFrame.""" return pd.DataFrame(mock_hfa_eligible_digital_physical_release_rows) @pytest.fixture def mock_hfa_eligible_digital_physical_release_rows(): """Return eligible digital physical tracks data.""" return [ { 'track_id': 101, 'track_isrc': 'USABC1234567', 'upc': '123456789012', 'release_id': 10, 'vendor_id': 3, 'hfa_configuration_code': 'SP', 'trans_type': 'digital', }, { 'track_id': 102, 'track_isrc': 'USDEF7654321', 'upc': '987654321098', 'release_id': 20, 'vendor_id': 3, 'hfa_configuration_code': 'CD', 'trans_type': 'physical', }, { 'track_id': 102, 'track_isrc': 'USDEF7654321', 'upc': '987654321098', 'release_id': 20, 'vendor_id': 3, 'hfa_configuration_code': 'LP', 'trans_type': 'physical', }, { 'track_id': 102, 'track_isrc': 'USDEF7654321', 'upc': '987654321098', 'release_id': 20, 'vendor_id': 3, 'hfa_configuration_code': 'CS', 'trans_type': 'physical', }, { 'track_id': 103, 'track_isrc': 'USGHI7654321', 'upc': '135789012346', 'release_id': 30, 'vendor_id': 1, 'hfa_configuration_code': 'SP', 'trans_type': 'digital', }, ] @pytest.fixture def mock_hfa_eligible_ringtone_rows(): """Return a list of dicts representing HFA eligible ringtone query results.""" return [ { 'track_id': 501, 'track_isrc': 'USXYZ1234567', 'upc': '112233445566', 'vendor_id': 3, 'release_id': 10, 'hfa_configuration_code': 'RT', 'trans_type': 'digital' }, { 'track_id': 502, 'track_isrc': 'USXYZ7654321', 'upc': '665544332211', 'vendor_id': 43, 'release_id': 20, 'hfa_configuration_code': 'RT', 'trans_type': 'digital' }, ] @pytest.fixture def mock_hfa_eligible_ringtone_df( mock_hfa_eligible_ringtone_rows ): """Return a HFA eligible ringtone DataFrame.""" return pd.DataFrame(mock_hfa_eligible_ringtone_rows) @pytest.fixture def mock_active_contracts_df(): """Return active contracts dataframe.""" rows = [ {'vendor_id': 1, 'physical_track': True, 'digital_track': True}, {'vendor_id': 2, 'physical_track': True, 'digital_track': False}, {'vendor_id': 3, 'physical_track': True, 'digital_track': True}, {'vendor_id': 4, 'physical_track': True, 'digital_track': False} ] return pd.DataFrame(rows).astype( {'vendor_id': 'int64', 'physical_track': 'bool', 'digital_track': 'bool'} ) @pytest.fixture def mock_active_contracts_rows(): """Return active contracts data.""" return { 1: {'mechadmin_digital': True, 'mechadmin_physical': True}, 2: {'mechadmin_digital': False, 'mechadmin_physical': True}, 3: {'mechadmin_digital': True, 'mechadmin_physical': True}, 4: {'mechadmin_digital': False, 'mechadmin_physical': True}, } @pytest.fixture def mock_merge_tracks_df(): """Return a merged DataFrame.""" data = { 'release_id': [10, 20, 30], 'vendor_id': [3, 1, 43] } return pd.DataFrame(data) @pytest.fixture def mock_carveouts_df(): """Return carveouts dataframe.""" return pd.DataFrame({ 'release_id': [10, 20, 30], 'has_us_carveout': [False, False, False] }) @pytest.fixture def mock_has_us_carveouts_df(): """Return US carveouts dataframe.""" return pd.DataFrame({ 'release_id': [10, 20, 30], 'has_us_carveout': [True, True, True] })