diff options
Diffstat (limited to 'opendc-web/opendc-web-api/conftest.py')
| -rw-r--r-- | opendc-web/opendc-web-api/conftest.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/opendc-web/opendc-web-api/conftest.py b/opendc-web/opendc-web-api/conftest.py index c502c078..430262f1 100644 --- a/opendc-web/opendc-web-api/conftest.py +++ b/opendc-web/opendc-web-api/conftest.py @@ -4,10 +4,11 @@ Configuration file for all unit tests. from functools import wraps import pytest -from flask import _request_ctx_stack +from flask import _request_ctx_stack, g +from opendc.database import Database -def decorator(self, f): +def decorator(f): @wraps(f) def decorated_function(*args, **kwargs): _request_ctx_stack.top.current_user = {'sub': 'test'} @@ -20,12 +21,14 @@ def client(): """Returns a Flask API client to interact with.""" # Disable authorization for test API endpoints - from opendc.util.auth import AuthManager - AuthManager.require = decorator + from opendc import exts + exts.requires_auth = decorator - from app import app + from app import create_app - app.config['TESTING'] = True + app = create_app(testing=True) - with app.test_client() as client: - yield client + with app.app_context(): + g.db = Database() + with app.test_client() as client: + yield client |
