"""conftest for integration tests.""" from os import getenv import time from auth.auth import GrassAuth, UserType import pytest from tests.utils.api_client import APIClient from tests.utils.local_client import LocalClient def workstation_session_token(user_id): """Initialize workstation grass auth token at start of test session.""" return GrassAuth(UserType.WORKSTATION, user_id).grass_token def oa_session_token(): """Initialize OA grass auth token at start of test session.""" return GrassAuth(UserType.OA).grass_token @pytest.fixture(scope='session') def workstation_user(): """Return data for workstation user.""" return {'user_id': 38271, 'vendor_id': 7123} @pytest.fixture def workstation_api_client(workstation_user): """Create APIClient object with Workstation session token.""" if getenv('QA_DB_PASS'): return APIClient( getenv( 'BASE_QA_URL', 'https://workstation.qaorch.com/grass'), workstation_session_token(workstation_user()['user_id'])) else: return LocalClient() @pytest.fixture def oa_api_client(): """Create APIClient object with QA URL and OA session token.""" if getenv('QA_DB_PASS'): return APIClient(getenv('BASE_QA_URL'), oa_session_token()) else: return LocalClient() @pytest.fixture def random_product_id(): """Create a product id using the timestamp for QA.""" return int(time.time())