"""Test graphql connector.""" EXPECTED_DISPLAY_STATUSES = ['submitted', 'completed', 'error_correction'] def test_get_indexable_product(graphql_connector_without_token_manager, mock_row): """Test getting an indexable product.""" index_record = graphql_connector_without_token_manager.get_indexable_product(mock_row) # Only check that notices are populated and correctly structured assert len(index_record.get('notices')) sample_notice = index_record.get('notices')[0] assert 'code' in sample_notice assert 'level' in sample_notice assert 'reason' in sample_notice record_omit_notices = { **index_record, 'notices': None } display_status = record_omit_notices.pop('display_status') assert display_status in EXPECTED_DISPLAY_STATUSES assert record_omit_notices == { 'account_id': '16162:0', 'account_name': 'Marketplace API Test Label', 'account_country': 'USA', 'account_country_code': 'US', 'added_at': mock_row.get('added_at'), 'assigned_reviewer_id': 2903, 'assigned_reviewer_name': 'Content Review', 'assigned_to_id': 187, 'assigned_to_name': 'Client Services', 'bulk_session_id': None, 'company_brand': { 'name': 'theorchard', 'uuid': 'd25a4cd1-e820-45f2-be5c-56edcfeb8298', 'displayName': 'The Orchard', }, 'company_brand_name': 'theorchard', 'company_brand_uuid': 'd25a4cd1-e820-45f2-be5c-56edcfeb8298', 'company_brand_display_name': 'The Orchard', 'configuration': 'Digital Audio', 'bulk_session_id': None, 'distribution_format_id': 1, 'escalation_type': None, 'featuring_artist': '', 'format': 'EP', 'genre_id': 5, 'genre_name': 'Folk', 'image_location': ( 'https://qa-images.theorchard.io/v2/product/cover/' '96f8203f1e2f4d26858a950a05fd5e1f_860a90e9_cbe0_4825_a2fe_4476029f7e61.jpeg' ), 'imprint': 'Meridian Records', 'label_id': 16162, 'label_owner': 'odd', 'label_name': 'Marketplace API Test Label', 'locked_by_user_id': None, 'locked_until_datetime': None, 'metadata_language_code': 'ENG', 'metadata_language_name': 'English', 'notices': None, 'preorder_date': None, 'primary_artist': 'T.S. Eliot', 'product_id': mock_row.get('product_id'), 'product_name': 'Graphql-Content-Review Integration Test Product', 'submission_count': 1, 'submission_type': 'New', 'release_correction_status': 'active', 'review_queue_id': mock_row.get('review_queue_id'), 'queue_name': 'initial', 'moved_to_group_name': None, 'moved_to_queue_by_user_id': None, 'moved_to_queue_by_user_name': None, 'moved_to_target_email': None, 'moved_to_target_id': None, 'moved_to_target_name': None, 'sale_start_date': '2021-11-04', 'secondary_internal_contact_id': 0, 'secondary_internal_contact_name': '', 'service_tier_name': 'Basic', 'service_tier_uuid': '5f2bd4fc-df94-4f35-97d3-ef23f8573279', 'special_instructions': None, 'subaccount_id': 0, 'subaccount_name': '', 'upc': '197189139093', 'submission_datetime': None, 'version': None } def test_get_base_product(graphql_connector_without_token_manager, mock_row): """Test getting an base product.""" index_record = graphql_connector_without_token_manager.get_base_product(mock_row) display_status = index_record.pop('display_status') assert display_status in EXPECTED_DISPLAY_STATUSES assert index_record == { 'assigned_reviewer_id': 2903, 'assigned_to_id': 187, 'company_brand': { 'name': 'theorchard', 'uuid': 'd25a4cd1-e820-45f2-be5c-56edcfeb8298', }, 'configuration': 'Digital Audio', 'distribution_format_id': 1, 'format': 'EP', 'label_id': 16162, 'label_owner': 'odd', 'product_id': mock_row.get('product_id'), 'product_name': 'Graphql-Content-Review Integration Test Product', 'release_correction_status': '', 'service_tier_name': 'Basic', 'service_tier_uuid': '5f2bd4fc-df94-4f35-97d3-ef23f8573279', 'subaccount_id': 0, 'upc': '197189139093' }