"""conftest for integration tests.""" from os import getenv from auth.auth import GrassAuth, UserType import pytest from tests.test_utils.api_client.api_client import APIClient from tests.test_utils.api_client.product_digital_api_client \ import ProductDigitalAPIClient @pytest.fixture(scope='session') def workstation_user(): """Return data for workstation user.""" return {'user_id': 38271, 'vendor_id': 7123} def workstation_session_token(user_id): """Initialize workstation grass auth token at start of test session.""" return GrassAuth(UserType.WORKSTATION, user_id).grass_token @pytest.fixture def workstation_api_client(workstation_user): """Create APIClient object with Workstation session token.""" return APIClient( getenv('BASE_QA_GRASS_URL'), workstation_session_token(workstation_user['user_id'])) @pytest.fixture def workstation_product_digital_api_client(workstation_user): """Create Product Digital APIClient with Workstation session token.""" return ProductDigitalAPIClient( getenv('BASE_QA_GRASS_URL'), workstation_session_token(workstation_user['user_id'])) @pytest.fixture def project_id(): """Return a Project ID from QA.""" return 3938193 @pytest.fixture def product_data(project_id): """Return a dictionary with product data.""" return {'format': 'Full Length', 'product_name': 'My Product', 'distribution_format_type': 'digital', 'upc': '', 'project_id': project_id, 'subaccount_id': None} @pytest.fixture def create_product(workstation_product_digital_api_client, product_data): """Create a new product and check response.""" product_response = workstation_product_digital_api_client.create_product( product_data) assert product_response.status_code == 201, \ 'Result of POST was {}, expected 201.'.format( product_response.status_code) return product_response.json()