"""Shared fixtures for tests.""" import os import pytest from abacus_adjustment.api import create_app from abacus_adjustment.config import Config class TestConfig(Config): """Test configuration.""" MYSQL_DB_NAME = os.environ.get( 'MYSQL_TEST_DB_NAME', Config.MYSQL_DB_NAME + '_test') @pytest.fixture(scope='session', autouse=True) def test_app(): """Create a test application.""" return create_app(TestConfig) @pytest.fixture(autouse=True) def test_app_in_context(test_app): """Push the test app onto the context.""" with test_app.app_context(): yield test_app @pytest.fixture(autouse=True) def test_app_request(test_app_in_context): """Push the test app onto the context and trigger preprocessing.""" with test_app_in_context.test_request_context(): test_app_in_context.preprocess_request() yield test_app_in_context @pytest.fixture def fixture_client(test_app_in_context): """Create a client fixture.""" with test_app_in_context.test_client() as test_client: yield test_client