"""Test extract product from message logic.""" from unittest.mock import patch from src.logic.extract_message_payload import extract_product_message_body @patch('src.logic.extract_message_payload.LambdaGraphQLConnector') def test_extract_product_message(mock_gql): """Test extracting product from message body.""" mock_product_record = { 'label_id': 1, 'label_owner': 'odd', 'company_brand': 'a-company-brand', 'assigned_to_id': 0, 'assigned_reviewer_id': 2, 'distribution_format_id': 1, } mock_gql.return_value.get_base_product.return_value = mock_product_record product_response = extract_product_message_body(1, 555) assert product_response == { 'release_id': 1, 'label_id': 1, 'label_owner': 'odd', 'company_brand': 'a-company-brand', 'assigned_to': 0, 'assigned_reviewer': 2, 'distribution_format_id': 1, } @patch('content_utils.connectors.graphql.HTTPEndpoint') def test_extract_full_data(mock_http_endpoint): """Test extracting a response.""" mock_data = { 'displayStatus': None, 'format': 'Full Length', 'productConfiguration': 'Digital Audio', 'productId': 4252489, 'productName': 'Once When We Were Birds', 'distributionFormatId': 1, 'upc': '197187814725', 'releaseCorrection': { 'status': 'submitted' }, 'label': { 'name': 'Silverfox Songs AB', 'owner': 'odd', 'id': { 'subaccountId': 0, 'vendorId': 33705 }, 'serviceTier': None, 'companyBrand': { 'uuid': 'd25a4cd1-e820-45f2-be5c-56edcfeb8298', 'name': 'theorchard' }, 'assignedTo': { 'id': 1 }, 'assignedReviewer': { 'id': 2 } } } mock_http_endpoint.return_value.return_value = { 'data': {'product': mock_data} } product_response = extract_product_message_body(4252489, 555) assert product_response == { 'release_id': 4252489, 'label_id': 33705, 'label_owner': 'odd', 'company_brand': { 'name': 'theorchard', 'uuid': 'd25a4cd1-e820-45f2-be5c-56edcfeb8298' }, 'assigned_to': 1, 'assigned_reviewer': 2, 'distribution_format_id': 1 }