"""Fixtures to use in tests.""" import pytest from flask import Flask from owsresponse import response from owsresponse.adaptors.flask import flaskify from werkzeug.exceptions import HTTPException from abacus_common_logic.connectors.database import db @pytest.fixture(scope='module', autouse=True) def test_app(): """Application with sqlite database fixture.""" def http_error_handler(error): return flaskify( response.create_error_response( message=error.description, status=error.code, code='error' ) ) app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app) app.app_context().push() db.create_all() app.register_error_handler(HTTPException, http_error_handler) return app @pytest.fixture def fixture_client(test_app): """Create a client fixture.""" with test_app.test_client() as test_client: yield test_client