"""Set up unit test environment.""" import uuid import pytest from content_review import config from content_review.constants import header config.ENVIRONMENT = config.TEST_ENVIRONMENT @pytest.fixture def post_header_validation_schema(): """Return typical schema for POST headers. Returns: (dict): schema """ schema = { 'properties': { header.GRASS_ACCOUNT_TYPE: { 'example': 'vendor', 'description': 'vendor | subaccount', 'type': 'string', 'pattern': '(vendor)|(subaccount)'}, header.GRASS_CONTENT_TYPE: { 'pattern': 'application/json', 'type': 'string'}, header.GRASS_ACCOUNT_ID: { 'type': 'string', 'pattern': '^\d+$', 'description': 'vendor_id | subaccount_id'}, header.GRASS_CORRELATION_ID: { 'type': 'string', 'description': 'UUID' } }, 'required': [ header.GRASS_ACCOUNT_TYPE, header.GRASS_CONTENT_TYPE, header.GRASS_ACCOUNT_ID ], 'type': 'object', '$schema': 'http://json-schema.org/draft-04/schema' } return schema @pytest.fixture def valid_post_header(valid_grass_account_vendor_id): """Return valid POST request headers. Returns: (dict): header dict """ data = { header.GRASS_CONTENT_TYPE: 'application/json', header.GRASS_CORRELATION_ID: '1234567890', header.GRASS_ACCOUNT_TYPE: 'vendor', header.GRASS_ACCOUNT_ID: str(valid_grass_account_vendor_id), header.GRASS_ORCHARD_USER_ID: 'alw:12345' } return data @pytest.fixture def valid_grass_account_vendor_id(): """Vendor id for testing.""" return 25257 @pytest.fixture def valid_headers(): """Return valid headers. Returns: dict: header dict """ return { header.GRASS_CORRELATION_ID: str(uuid.uuid4()), header.GRASS_ACCOUNT_TYPE: 'vendor', header.GRASS_ACCOUNT_ID: '1234'} @pytest.fixture def valid_body(): """Return valid body. Returns: dict: body dict """ return { 'some_property': 'test' } @pytest.fixture def invalid_body(): """Return invalid body. Returns: dict: body dict """ return { 'some_property': 100 } @pytest.fixture def example_body_schema(): """Return example body payload.""" return { '$schema': 'http://json-schema.org/draft-04/schema', 'type': 'object', 'additionalProperties': False, 'properties': { 'some_property': { 'type': 'string' } }, 'required': ['some_property'] }