summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-api/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-api/conftest.py')
-rw-r--r--opendc-web/opendc-web-api/conftest.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/opendc-web/opendc-web-api/conftest.py b/opendc-web/opendc-web-api/conftest.py
index 8bb55ccc..c502c078 100644
--- a/opendc-web/opendc-web-api/conftest.py
+++ b/opendc-web/opendc-web-api/conftest.py
@@ -1,14 +1,30 @@
"""
Configuration file for all unit tests.
"""
+
+from functools import wraps
import pytest
+from flask import _request_ctx_stack
+
-from app import app
+def decorator(self, f):
+ @wraps(f)
+ def decorated_function(*args, **kwargs):
+ _request_ctx_stack.top.current_user = {'sub': 'test'}
+ return f(*args, **kwargs)
+ return decorated_function
@pytest.fixture
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 app import app
+
app.config['TESTING'] = True
with app.test_client() as client: