Commit 815dd77b authored by Hugo Kerstens's avatar Hugo Kerstens

Add app fixture for testing

parent a0be891d
import os
import pytest
from flask import Flask
from zesje.api import api_bp
from zesje.database import db
# Adapted from https://stackoverflow.com/a/46062148/1062698
@pytest.fixture
def datadir():
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
@pytest.fixture(scope="module")
def app():
app = Flask(__name__, static_folder=None)
app.config.update(
SQLALCHEMY_DATABASE_URI='sqlite:///:memory:',
SQLALCHEMY_TRACK_MODIFICATIONS=False # Suppress future deprecation warning
)
db.init_app(app)
with app.app_context():
db.drop_all()
db.create_all()
app.register_blueprint(api_bp, url_prefix='/api')
return app
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment