"""conftest. This file gets picked up when running py.test tests: http://pytest.org/latest/writing_plugins.html#conftest """ import application from owslogger import flask_logger import pytest from product_digital_marketing.constants import header as header_consts @pytest.fixture def client(): """Return flask test client. Returns: flask client: flask test client """ return application.app.test_client() @pytest.fixture def context(): """Return flask app context, including a mock logger. Returns: AppContext: flask app context, including a mock logger. """ class MockLog(): """Mock Logging Class.""" def error(self): pass def info(self): pass def warning(self): pass context = application.app.app_context() context.g.ows = flask_logger.Ows() context.g.ows.log = MockLog return context @pytest.fixture def client_headers(): """Return test headers when using test client for functional tests. Returns: dict: header values. """ return { header_consts.CORRELATION_ID: 'abc-123', header_consts.CONTENT_TYPE: header_consts.CONTENT_TYPE_JSON_VAL, } @pytest.fixture def grass_headers(): """Return test headers when using test client for functional tests. Returns: dict: header values. """ return { header_consts.GRASS_ACCOUNT_TYPE: header_consts.GRASS_ACCOUNT_TYPE_VENDOR, header_consts.GRASS_ACCOUNT_ID: '1234', header_consts.CORRELATION_ID: 'abc-123', header_consts.CONTENT_TYPE: header_consts.CONTENT_TYPE_JSON_VAL, header_consts.ORCHARD_USER_ID: 'alw:123' }