41 lines
762 B
Python
41 lines
762 B
Python
# Library imports
|
|
import pytest
|
|
|
|
# Import flask app factory function
|
|
from app_factory import add_test_data
|
|
from app_factory import create_app
|
|
|
|
# Import db
|
|
from accounts.models import db as _db
|
|
|
|
####
|
|
# Global fixtures
|
|
####
|
|
|
|
# App client for testing
|
|
@pytest.fixture(scope='module')
|
|
def app():
|
|
app = create_app(config_class='tests/testing_config.py')
|
|
with app.app_context():
|
|
yield app
|
|
|
|
# DB for testing
|
|
@pytest.fixture(scope='module')
|
|
def db(app):
|
|
_db.init_app(app)
|
|
_db.create_all()
|
|
add_test_data(_db)
|
|
|
|
yield _db
|
|
|
|
_db.session.remove()
|
|
_db.drop_all()
|
|
|
|
# HTTP client for testing app routes
|
|
@pytest.fixture(scope='module')
|
|
def http_client():
|
|
app = create_app(config_class='testing_config.py')
|
|
|
|
return app.test_client()
|
|
|